mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 18:03:36 +00:00
Add MercuryFatalError exception to the Java runtime.
Add MercuryFatalError, a new Java exception that is intended to be used for a
similar purpose to the C runtime's MR_fatal_error() function.
Throw a MercuryFatalError exception instead of calling System.exit() in a spot.
Calling exit() is fine for executables, but for code that is deployed in an
application server calling exit() may shut down the entire server.
java/runtime/MercuryFatalError.java:
Add the new exception.
java/runtime/MercuryOptions.java:
Do not call System.exit() when we encounter an unrecognized
option in MERCURY_OPTIONS, throw a MercuryFatalError exception
instead.
Refactor the process() method in order to avoid indentation.
Catch NumberFormatExceptions thrown when attempting to convert
integer option values; rethrow them as MercuryFatalErrors.
(XXX the C version of the runtime just ignores this error.)
java/runtime/JavaInternal.java:
Catch and report MercuryFatalErrors in the runMain() method.
java/runtime/MercuryWorkerThread.java:
Add an XXX about a call to System.exit() here.
This commit is contained in:
@@ -77,7 +77,17 @@ public class JavaInternal {
|
||||
*/
|
||||
public static void runMain(Runnable main)
|
||||
{
|
||||
getThreadPool().runMain(main);
|
||||
try {
|
||||
getThreadPool().runMain(main);
|
||||
} catch (jmercury.runtime.MercuryFatalError e) {
|
||||
System.out.flush();
|
||||
System.err.println("Mercury runtime: " + e.getMessage());
|
||||
System.err.flush();
|
||||
|
||||
if (exit_status == 0) {
|
||||
exit_status = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user