a strange idea comes to me when I'm reading APUE(Advanced Programming in UNIX Environment).
It seems that in UNIX's error handling, there are two types of errors (FATAL & INFATAL). I feel like it's something related to checked and unchecked Exceptions in JAVA.
So, to sum up, in a program, you have two kinds of errors, one of them is critical and will make system crash and you can do nothing about it. Another one is more like a signal that you can catch and do something to fix it.
I heard that in C# there is no checked and unchecked exception, so does C# not have a concept of critical and uncritical errors? Just got very curious because i think this concept is very fundamental.
Update: What is the exception design in other languages? Can anyone talk about this?
In Java, checked and unchecked exceptions don't exactly map to a fatal or non-fatal error. A checked exception explicitly is stating that the exception may be thrown and someone must catch it (to try to handle it or throw it up the stack), but there is no guarantee that the error may not be fatal (i.e. a syntax error in an SQL query will throw an SQLException and will likely be fatal, but it is a checked exception). An unchecked exception just means that someone doesn't need to catch it, but you still can if you want. It would typically indicate a programming error. Java Errors typically indicate things that are unrecoverable problems (such as an OutOfMemoryError).
The C# design of unchecked exceptions just means you don't need to catch the exceptions, and if uncaught will crash the application. Checked vs unchecked exceptions has been a long standing debate in the development community and there are pros and cons to both. Typically though, you can't do something about an exception and it frequently just ends up getting logged rather than handled, so C# made exceptions unchecked. When you can handle them (for example, if you want to retry an IO operation), you can still catch them and retry.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With