package com.suse.studio.client.exception;

import java.io.IOException;

/**
 * An error that occurred during a request to SUSE Studio.
 */
public class SUSEStudioException extends Exception {

    /**
     * Serial version uid.
     */
    private static final long serialVersionUID = -7929499514444458368L;

    /**
     * A SUSE Studio error code.
     * 
     * @see http://susestudio.com/help/api/v2/general.html
     */
    private String code;

    /**
     * An explanation of the error.
     */
    private String message;

    /**
     * An I/O exception if this exception was caused by an I/O error condition.
     */
    private IOException cause;

    /**
     * Standard constructor.
     * 
     * @param code
     * @param message
     */
    public SUSEStudioException(String code, String message) {
        super();
        this.code = code;
        this.message = message;
    }

    /**
     * Alternate constructor for I/O errors.
     * 
     * @param cause
     */
    public SUSEStudioException(IOException cause) {
        this(null, cause.getMessage());
        this.cause = cause;
    }

    /**
     * Returns a SUSE Studio error code.
     * 
     * @see http://susestudio.com/help/api/v2/general.html
     */
    public String getCode() {
        return code;
    }

    /**
     * Returns an explanation of the error.
     */
    public String getMessage() {
        return message;
    }

    /**
     * Returns the causing IOException, if this exception was caused by an I/O error condition.
     */
    public IOException getCause() {
        return cause;
    }

    @Override
    public String toString() {
        if (getCode() != null) {
            return "SUSE Studio error \"" + getCode() + "\": " + getMessage();
        } else {
            return "I/O error:" + getMessage();
        }
    }
}

@@ -40,37 +40,8 @@
 n;%0A%0A
-import java.io.IOException;%0A%0A
 /**%0A
@@ -500,136 +500,8 @@
 e;%0A%0A
-    /**%0A     * An I/O exception if this exception was caused by an I/O error condition.%0A     */%0A    private IOException cause;%0A%0A
     
@@ -757,16 +757,18 @@
 Alternat
+iv
 e constr
@@ -777,30 +777,45 @@
 tor 
-for I/O errors
+expecting a %7B@link Throwable%7D
 .%0A     *
  %0A  
@@ -802,33 +802,32 @@
 rowable%7D.%0A     *
- 
 %0A     * @param c
@@ -830,16 +830,36 @@
 am cause
+ the exception cause
 %0A     */
@@ -890,27 +890,25 @@
 ception(
-IOException
+Throwable
  cause) 
@@ -921,37 +921,19 @@
     
-this(null, cause.getMessage()
+super(cause
 );%0A 
@@ -944,20 +944,22 @@
    this.
-caus
+messag
 e = caus
@@ -955,24 +955,37 @@
 sage = cause
+.getMessage()
 ;%0A    %7D%0A%0A   
@@ -1291,185 +1291,8 @@
  %7D%0A%0A
-    /**%0A     * Returns the causing IOException, if this exception was caused by an I/O error condition.%0A     */%0A    public IOException getCause() %7B%0A        return cause;%0A    %7D%0A%0A
     

Simplify exception code and allow any Throwable as cause