001/*
002 * ModeShape (http://www.modeshape.org)
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.modeshape.web.shared;
017
018import com.google.gwt.user.client.rpc.IsSerializable;
019
020/**
021 *
022 * @author kulikov
023 */
024public class RemoteException extends Exception implements IsSerializable {
025    public final static int SECURITY_ERROR = 1;
026    
027    private static final long serialVersionUID = 1L;
028    private int code;
029    private String msg;
030    
031    public RemoteException() {
032        super();
033    }
034
035    public RemoteException(String e) {
036        super(e);
037    }
038    
039    public RemoteException(int code, String e) {
040        super(e);
041        this.code = code;
042    }
043    
044    public RemoteException(Exception e) {
045        msg = e.getMessage();
046        if (msg == null || msg.length() == 0) {
047            msg = e.getClass().getName();
048        }
049    }
050    
051    @Override
052    public String getMessage() {
053        return msg != null ? msg : super.getMessage();
054    }
055    
056    public int code() {
057        return code;
058    }
059}