|
| 1 | +/* |
| 2 | + * (c) Copyright 2018 Palantir Technologies Inc. All rights reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.palantir.remoting.api.errors; |
| 18 | + |
| 19 | +/** |
| 20 | + * An exception thrown by an RPC client to indicate remote/server-side failure from a non-remoting server. |
| 21 | + */ |
| 22 | +public final class UnknownRemoteException extends RuntimeException { |
| 23 | + private static final long serialVersionUID = 1L; |
| 24 | + |
| 25 | + private final int status; |
| 26 | + private final String body; |
| 27 | + |
| 28 | + /** The HTTP status code of the HTTP response conveying the error. */ |
| 29 | + public int getStatus() { |
| 30 | + return status; |
| 31 | + } |
| 32 | + |
| 33 | + /** Returns the body of the error response. */ |
| 34 | + public String getBody() { |
| 35 | + return body; |
| 36 | + } |
| 37 | + |
| 38 | + public UnknownRemoteException(int status, String body) { |
| 39 | + super(String.format("Error %s. (Failed to parse response body as SerializableError.)", status)); |
| 40 | + this.status = status; |
| 41 | + this.body = body; |
| 42 | + } |
| 43 | + |
| 44 | +} |
0 commit comments