class A
{
void test()
{
writeln("test");
}
}
try
{
A a = null;
a.test();
}catch(Throwable t)
{
writeln(t.msg);
}
The code above will not print a exception message, but crashes
instead.
I dont think this a good choice for most scenes. For example,I
developed many modules in my server, and add a new module now. If
null exception happens, I hope the server continue running, not
crash. If the server continue running, the functions offered by
old modules can be used by users, only the new module stop
serving.
In short words, I want to catch something like
NullPointerException.
Is this possible?