|
| 1 | +/* |
| 2 | + * Copyright 2013-2015 the original author or authors. |
| 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 | +package org.springframework.hateoas; |
| 17 | + |
| 18 | +import org.springframework.hateoas.VndErrors.VndError; |
| 19 | + |
| 20 | +/** |
| 21 | + * A base exception used for propagating the {@link VndErrors} received from remote service call. |
| 22 | + * |
| 23 | + * @author Jakub Narloch |
| 24 | + * @see VndErrors |
| 25 | + */ |
| 26 | +public class VndErrorException extends RuntimeException { |
| 27 | + |
| 28 | + private final VndErrors errors; |
| 29 | + |
| 30 | + /** |
| 31 | + * Creates new instance of {@link VndErrorException} with the single {@link VndError}. |
| 32 | + * |
| 33 | + * @param error the error |
| 34 | + */ |
| 35 | + public VndErrorException(VndError error) { |
| 36 | + this.errors = new VndErrors(error); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * Creates new instance of {@link VndErrorException} with {@link VndErrors}. |
| 41 | + * |
| 42 | + * @param errors the errors |
| 43 | + */ |
| 44 | + public VndErrorException(VndErrors errors) { |
| 45 | + this.errors = errors; |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Creates new instance of {@link VndErrorException} with detailed error message and {@link VndErrors}. |
| 50 | + * |
| 51 | + * @param message the detailed error message |
| 52 | + * @param errors the errors |
| 53 | + */ |
| 54 | + public VndErrorException(String message, VndErrors errors) { |
| 55 | + super(message); |
| 56 | + this.errors = errors; |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Creates new instance of {@link VndErrorException} with detailed error message, inner cause and {@link VndErrors}. |
| 61 | + * |
| 62 | + * @param message the detailed error message |
| 63 | + * @param cause the inner cause |
| 64 | + * @param errors the errors |
| 65 | + */ |
| 66 | + public VndErrorException(String message, Throwable cause, VndErrors errors) { |
| 67 | + super(message, cause); |
| 68 | + this.errors = errors; |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * Retrieves the errors. |
| 73 | + * |
| 74 | + * @return the errors |
| 75 | + */ |
| 76 | + public VndErrors getErrors() { |
| 77 | + return errors; |
| 78 | + } |
| 79 | +} |
0 commit comments