Meaningful error messages are good. Period. A lot of software badly sucks at this point. They throw "an error happened" or show a strange behaviour, but they don't say, that they cannot open a file because of missing access rights. I stress in application guidelines for java software, that every exception is getting caught and at least logged at an warning loglevel. This mechanism offers the possibility to increase the loglevel from the usual "ERROR" to something like "INFO" if we're debugging an issue.
Recently we had the issue that the partition for logs went full and the logging stopped. Then we cleaned up a little bit but there still was no logging. The only solution was to restart the application.
Today I wanted to reproduce this issue using
a little test program. I dug out my java programming experience and wrote a little programm which should constantly try to write to a file until the filesystem is full. After having freed up some space on the filesystem this programm should proceed writing.
But instead of checking this issue I found a totally different problem:
I used the
example code showed on the Java documentation:
PrintWriter out
= new PrintWriter(new BufferedWriter(new FileWriter("foo.out")));
Hm, no exception is getting thrown even when the filesystem, but strace shows that this programm gets an -ENOSPACE. Very strange. Looking up
the documentation of PrintWriter revealed, that after every call we have to call the method checkError to find out if we hit the wall. And all methods (write, flush, etc) don't have a return type to indicate an error, of course. Why do we have a concept like exceptions?
Rewritting the application to omitt the use of this PrintWriter class proved that these exception are thrown, but the PrintWriter has been designed by an really bad C programmer just to catch all exceptions and to have a single "there has been an error" flag.
Good old errno ...
Ok, PrintWriter is getting blacklisted. Why is such crap still contained in java?