logo separator

[mkgmap-dev] Mkgmap always returns exit code 0 even when it fails

From Gerd Petermann gpetermann_muenchen at hotmail.com on Tue Jan 14 05:23:33 GMT 2014

Hi Paco,

> No, Ant checks for the return code : I invoke the java task with the failonerror
> attribute (http://ant.apache.org/manual/Tasks/java.html#failonerror) which
> explicitly mentions the result code. The result code is set in the Java code
> with the System.exit() method.
yes, that's what ant does. My question was how you decide that mkgmap failed.

> 
> > so maybe we can check whether anything was
> > written to stderr, but sometimes we use this file also for
> > important hints like this:
> > "WARNING: input files have different code pages"
> 
> I agree with you, mkgmap outputs lots of warnings, this workaround would be
> tricky at best. It would work if we output information and warnings to stdout
> and errors and exceptions to stderr but that requires a check on the complete
> codebase.
> 
> I ran a grep for System.exit on the codebase and found several calls to
> System.exit(), adding a few of them in the right places (e.g. at the end of the
> options processing, catching any exception mkgmap can't deal with...) should do
> the trick.
> Forgive me if I'm wrong here, it's been 10 years since I wrote a single line of
> java code.

your welcome. In fact only very few of the System.exit() calls are reachable if
your execute mkgmap main. They are used in stand-alone programs.

Anyhow, I think we should at least manage to stop with non zero return code 
when parameter checks fail or input files are missing or if one output file 
was not not completely written.
It is much more difficult to keep track of error messages regarding the quality of the
output.

> > BTW: Also splitter doesn't make sure that it ends
> > with a non-zero return code in case of errors, but
> > it tries to do so.
> 
> As far as I remember, I've run into incorrect options or missing file errors,
> splitter always behaved as expected.
yes, those typical user errors are probably all catched.
One example that is not: if the input is an invalid o5m file you might see a traceback but splitter
ends with rc 0. 

Gerd
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20140114/5c7fc958/attachment.html>


More information about the mkgmap-dev mailing list