001package org.nuxeo.box.api.marshalling.exceptions;
002
003import org.nuxeo.ecm.webengine.WebException;
004
005/**
006 * BoxException, this is an exception thrown from executing the api requests.
007 */
008public class BoxRestException extends WebException {
009
010    /**
011     * Default serial version uid.
012     */
013    private static final long serialVersionUID = 1L;
014
015    private String mMessage;
016
017    private int errorCode;
018
019    /**
020     * BoxRestException.
021     *
022     * @param message Message of the exception.
023     */
024    public BoxRestException(String message) {
025        this.mMessage = message;
026    }
027
028    /**
029     * BoxRestException.
030     *
031     * @param exception raw exception.
032     * @param message customized exception message.
033     */
034    public BoxRestException(Exception exception, String message) {
035        super(exception);
036        this.mMessage = message;
037    }
038
039    /**
040     * BoxRestException.
041     *
042     * @param message customized exception message.
043     * @param errorCode customized exception error code.
044     */
045    public BoxRestException(String message, int errorCode) {
046        this(message);
047        this.errorCode = errorCode;
048    }
049
050    /**
051     * BoxRestException.
052     *
053     * @param e raw exception.
054     */
055    public BoxRestException(Exception e) {
056        super(e);
057    }
058
059    public BoxRestException(String message, Exception e, int errorCode) {
060        super(e);
061        this.mMessage = message;
062        this.errorCode = errorCode;
063    }
064
065    @Override
066    public String getMessage() {
067        return mMessage;
068    }
069
070    /**
071     * Get the customized exception error code.
072     *
073     * @return error code.
074     */
075    public int getErrorCode() {
076        return errorCode;
077    }
078}