
C#
In C# Exception (root of all exceptions) extends base class Exception : ISerializable and then differs logically between SystemException and ApplicationException.
ExternalException, Win32Exception, WebException, IOException, SocketException and all exceptions thrown during os system operations extend SystemException or it's children.
Java
In Java Throwable (root of all errors & exceptions) extends base class object. Error and Exception both extend from Throwable.
Errors such StackOverflowError (endless recursion), OutOfMemoryError (endless allocation) and VirtualMachineError are thrown, when critical limits of java virtual machine exceeded.
In java some exceptions like IOException or SocketException are "checked at compile time". This does NOT mean, that javac compiler knows when IOException or SocketExcpetion will be thrown at program flow at runtime.
Furthermore javac compiler knows if reading from or writing to a file needs catching an IOExceptiuon, because disk might be full or USB stick could be unplugged or fs mount point is now unmounted or remounter ro. When reading from or writing to a socket javac compiler knows, that you must catch a SocketException in case of a linux system init runlevel 1 or 2, unplugging USB network adapter or dog bites CAT5 or CAT7 network cable.
C++
In C++ there is no binary split at the root of "exception tree" as in C# (System Exception &ApplicationException) or in Java (Error & Exception both extend from Throwable).
In C++ bad_cast, bad_alloc, bad_function_call, logic_error & runtime_error extend from exception.
Most common Exceptions in C++ extend from logic_error & runtime_error.b.
Keine Kommentare:
Kommentar veröffentlichen