#906 – Adding Custom Data vs. Using a Custom Exception Type

There are two basic approaches to adding custom data to an exception that you’re going to throw.  In both cases, you can pass data back to the calling method that is unique to the specific problem that has occurred.

You can use either method, depending on the knowledge that your calling code has regarding either your custom exception type or the custom data that you add to the exception.  Creating a custom exception type gives you some more flexibility, because calling code can then add a handler that is specific to the new type.

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: