0

In Java, there are two types of Exceptions, mainly unchecked and checked exceptions. Checked exceptions allow the program to recover when they are caught and handled in a ‘catch’ block. Unchecked exceptions just cause your program to crash, since they are not caught and the error bubbles up all the way got the main method without being caught, if I recall correctly.

That said, in Mono, there are ApplicationExceptions and SystemExceptions and I was wondering if these serve the same purpose in mono.

leeand00
  • 25,510
  • 39
  • 140
  • 297

1 Answers1

1

No they are not. The distinctions are different.

In Java, the checked versus unchecked distinction is about whether Java code needs to deal with the exception:

  • unchecked exceptions don't need to be dealt with
  • checked exceptions need to be either caught or declared in the signature of the enclosing method.

(You should chose between declaring an exception as checked or unchecked according to whether you expect / want the caller to handle it. For example, you typically want the app to do something to recover from an IOException, but a NullPointerException is usually a bug and cannot be handled beyond logging and bailing out.)


By contrast, ApplicationExceptions versus SystemExceptions in .NET is about the meaning of the exceptions; see Difference Between Application Exception and System Exception. The ostensible purpose was to allow a program to distinguish between framework and custom exceptions. (But it doesn't really work ... in practice ... because programmers don't follow the guidelines / conventions.)


I'm checking really only to see if the distinction would crash a running program if SystemException was thrown instead of an ApplicationException

You can't make that generalization. The application crashes if either kind of exception (or any other kind) is thrown and not caught1. And that is true for Java exceptions as well.

1 - In Java, this depends on the behavior of the default exception handler.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216