From 2004958ec0f34fb765c72b0ea7d09b805e60eaa5 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Tue, 19 Jan 2010 21:03:07 +0000 Subject: [PATCH] added custom exception type git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@26103 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/os/PosixAPI.java | 2 +- .../main/java/hudson/os/PosixException.java | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/hudson/os/PosixException.java diff --git a/core/src/main/java/hudson/os/PosixAPI.java b/core/src/main/java/hudson/os/PosixAPI.java index c79bed2bed..a36cbddf1c 100644 --- a/core/src/main/java/hudson/os/PosixAPI.java +++ b/core/src/main/java/hudson/os/PosixAPI.java @@ -31,7 +31,7 @@ public class PosixAPI { private static final POSIX posix = POSIXFactory.getPOSIX(new POSIXHandler() { public void error(ERRORS errors, String s) { - throw new RuntimeException(s+" "+errors); + throw new PosixException(s,errors); } public void unimplementedError(String s) { diff --git a/core/src/main/java/hudson/os/PosixException.java b/core/src/main/java/hudson/os/PosixException.java new file mode 100644 index 0000000000..93e96ef5d0 --- /dev/null +++ b/core/src/main/java/hudson/os/PosixException.java @@ -0,0 +1,26 @@ +package hudson.os; + +import org.jruby.ext.posix.POSIX.ERRORS; + +/** + * Indicates an error during POSIX API call. + * + * @author Kohsuke Kawaguchi + */ +public class PosixException extends RuntimeException { + private final ERRORS errors; + + public PosixException(String message, ERRORS errors) { + super(message); + this.errors = errors; + } + + public ERRORS getErrorCode() { + return errors; + } + + @Override + public String toString() { + return super.toString()+" "+errors; + } +}