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 CanNotCreateFileError Can't create (user) output file. |
CommandLineUsageError | shared CommandLineUsageError Command line usage error, e.g. missing argument for option. |
ConfigurationError | shared ConfigurationError Wrong configuration. |
DataFormatError | shared DataFormatError Data format error, e.g. passing a input file with wrong type. |
IOError | shared IOError Input/output error. |
InternalSoftwareError | shared InternalSoftwareError Internal software error. |
NoHostError | shared NoHostError Host name unknown. |
NoInputError | shared NoInputError Cannot open input. |
NoPermissionError | shared NoPermissionError permission denied. |
NoUserError | shared NoUserError Addressee unknown. |
NotImplementedException | shared NotImplementedException Similar to UnsupportedOperationException in Java. |
NotImplementedYetException | shared NotImplementedYetException Features will be implemented in future. |
OSFileError | shared OSFileError Critical OS file missing. |
RemoteError | shared RemoteError Remote error. |
ServiceUnavailableError | shared ServiceUnavailableError Service unavailable. |
SysexitsException | shared abstract SysexitsException Super classes of all sysexits exceptions. |
SystemError | shared SystemError Low level system error, e.g. jvm and js runtime error or os error. |
TempFailureError | shared TempFailureError Temp failure; user is invited to retry. |