Exceptions mapping sysexits.h.
They are likely to be caught by void run(), for example:
"The ultimate exception handler."
suppressWarnings("expressionTypeNothing")
shared void run() {
try {
main();
} catch (ConfigurationError e) {
process.writeErrorLine(e.message);
process.exit(e.exit_code);
}
}
Exceptions mapping sysexits.h are named with postfix Error,
and extends Exception.
You can extends them to represent more concrete exceptions.
For example, this module also provides NotImplementedException,
which is defined as
shared class NotImplementedException(String message)
extends InternalSoftwareError(message) {}
You can implement your own exception with customize exit_code,
which extends abstract class SystexitsException.
For example:
"When following redirects, hit the maximum amount."
shared class TooManyRedirects(String message) extends SysexitsException(message) {
"The exit code is borrowed from curl."
shared actual Integer exit_code 47;
}
| Packages | |
| io.github.weakish.sysexits | Maps sysexits.h to Ceylon exceptions, except |
Maps sysexits.h to Ceylon exceptions, except EX_OK.
All exceptions extend SysexitsException.
#define EX_USAGE 64 /* command line usage error */ #define EX_DATAERR 65 /* data format error */ #define EX_NOINPUT 66 /* cannot open input */ #define EX_NOUSER 67 /* addressee unknown */ #define EX_NOHOST 68 /* host name unknown */ #define EX_UNAVAILABLE 69 /* service unavailable */ #define EX_SOFTWARE 70 /* internal software error */ #define EX_OSERR 71 /* system error (e.g., can't fork) */ #define EX_OSFILE 72 /* critical OS file missing */ #define EX_CANTCREAT 73 /* can't create (user) output file */ #define EX_IOERR 74 /* input/output error */ #define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ #define EX_PROTOCOL 76 /* remote error in protocol */ #define EX_NOPERM 77 /* permission denied */ #define EX_CONFIG 78 /* configuration error */
| Exceptions | |
CanNotCreateFileError | shared CanNotCreateFileErrorCan't create (user) output file. |
CommandLineUsageError | shared CommandLineUsageErrorCommand line usage error, e.g. missing argument for option. |
ConfigurationError | shared ConfigurationErrorWrong configuration. |
DataFormatError | shared DataFormatErrorData format error, e.g. passing a input file with wrong type. |
IOError | shared IOErrorInput/output error. |
InternalSoftwareError | shared InternalSoftwareErrorInternal software error. |
NoHostError | shared NoHostErrorHost name unknown. |
NoInputError | shared NoInputErrorCannot open input. |
NoPermissionError | shared NoPermissionErrorpermission denied. |
NoUserError | shared NoUserErrorAddressee unknown. |
NotImplementedException | shared NotImplementedExceptionSimilar to UnsupportedOperationException in Java. |
NotImplementedYetException | shared NotImplementedYetExceptionFeatures will be implemented in future. |
OSFileError | shared OSFileErrorCritical OS file missing. |
RemoteError | shared RemoteErrorRemote error. |
ServiceUnavailableError | shared ServiceUnavailableErrorService unavailable. |
SysexitsException | shared abstract SysexitsExceptionSuper classes of all sysexits exceptions. |
SystemError | shared SystemErrorLow level system error, e.g. jvm and js runtime error or os error. |
TempFailureError | shared TempFailureErrorTemp failure; user is invited to retry. |