package us.kbase.auth2.lib.exceptions;

/** Base class of all authorization service exceptions.
 * @author gaprice@lbl.gov 
 */
@SuppressWarnings("serial")
public class AuthException extends Exception {
	
	private final AuthError err;
	
	public AuthException(final AuthError err, final String message) {
		super(err.getErrorCode() + " " + err.getError() + ": " + message);
		this.err = err;
	}
	
	public AuthException(
			final AuthError err,
			final String message,
			final Throwable cause) {
		super(err.getErrorCode() + " " + err.getError() + ": " + message,
				cause);
		this.err = err;
	}

	public AuthError getErr() {
		return err;
	}
}

@@ -309,85 +309,313 @@
 per(
-err.getErrorCode() + %22 %22 + err.getError() + %22: %22 + message);%0A%09%09this.err = err
+getMsg(err, message));%0A%09%09this.err = err;%0A%09%7D%0A%0A%09private static String getMsg(final AuthError err, final String message) %7B%0A%09%09if (err == null) %7B%0A%09%09%09throw new NullPointerException(%22err%22);%0A%09%09%7D%0A%09%09return err.getErrorCode() + %22 %22 + err.getError() + %0A%09%09%09%09(message == null %7C%7C message.isEmpty() ? %22%22 : %22: %22 + message)
 ;%0A%09%7D
@@ -729,66 +729,27 @@
 per(
-err.getErrorCode() + %22 %22 + err.getError() + %22: %22 +
+getMsg(err,
  message
 ,%0A%09%09
@@ -740,24 +740,25 @@
 err, message
+)
 ,%0A%09%09%09%09cause)

handle null errors