001/* 002 * Copyright 2013 Box, Inc. All rights reserved. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.nuxeo.box.api.marshalling.exceptions; 017 018import org.nuxeo.ecm.webengine.WebException; 019 020/** 021 * BoxException, this is an exception thrown from executing the api requests. 022 */ 023public class BoxRestException extends WebException { 024 025 /** 026 * Default serial version uid. 027 */ 028 private static final long serialVersionUID = 1L; 029 030 private String mMessage; 031 032 private int errorCode; 033 034 /** 035 * BoxRestException. 036 * 037 * @param message Message of the exception. 038 */ 039 public BoxRestException(String message) { 040 this.mMessage = message; 041 } 042 043 /** 044 * BoxRestException. 045 * 046 * @param exception raw exception. 047 * @param message customized exception message. 048 */ 049 public BoxRestException(Exception exception, String message) { 050 super(exception); 051 this.mMessage = message; 052 } 053 054 /** 055 * BoxRestException. 056 * 057 * @param message customized exception message. 058 * @param errorCode customized exception error code. 059 */ 060 public BoxRestException(String message, int errorCode) { 061 this(message); 062 this.errorCode = errorCode; 063 } 064 065 /** 066 * BoxRestException. 067 * 068 * @param e raw exception. 069 */ 070 public BoxRestException(Exception e) { 071 super(e); 072 } 073 074 public BoxRestException(String message, Exception e, int errorCode) { 075 super(e); 076 this.mMessage = message; 077 this.errorCode = errorCode; 078 } 079 080 @Override 081 public String getMessage() { 082 return mMessage; 083 } 084 085 /** 086 * Get the customized exception error code. 087 * 088 * @return error code. 089 */ 090 public int getErrorCode() { 091 return errorCode; 092 } 093}