What is Throwing an Exception?

At this point in the video Ben talks about “throwing” something. This is the first time we have come across this in the course. Can someone provide a succinct definition?

Is it perhaps in reference to throwing an exception?

Yes and What it means?

1 Like

Throwing an exception is effectively saying “I have a problem, something unexpected has happened”.

There are many types of exception, I have provided a little list in the links below, be sure to scroll down passed all of the exceptions/links to see further information.

One common one that you may see is a Null Reference Exception, these are generated when you try to access a member (variable, property or method for example) of an object that has not been instantiated.

In addition, you can throw your own exceptions, for example;

public void Start()
    AutomaticallyMakeForMeTheMostAwesomeGameEver();    // call our make game function

private void AutomaticallyMakeForMeTheMostAwesomeGameEver()
    throw new NotImplementedException("Someone should really write this function one day!");

Hope this helps :slight_smile:

See also;

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms