I’ve built a socket server which logs all it proccesses in a text file.
For now, the server runs in the background and has no UI.
Is there a way for me to catch ALL run time errors (not just the ones throwing exeptions) include null pointers etc. and log it to a file for monitoring?
Yes, it is simple to catch anything that can be thrown in Java. You just need to catch the base class of everything throwable:
A note on terminology: everything that can be thrown in Java is called an “exception”, not only the exceptions extending from the
Exceptionclass. This is an unfortunate choice of class names, possibly due to a late decision in Java design to introduce a superclass toException.