|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +package org.apache.xtable.model.sync; |
| 20 | + |
| 21 | +import lombok.Builder; |
| 22 | +import lombok.Value; |
| 23 | + |
| 24 | +import org.apache.xtable.MaturityLevel; |
| 25 | +import org.apache.xtable.PublicAPIClass; |
| 26 | + |
| 27 | +@Value |
| 28 | +@Builder |
| 29 | +@PublicAPIClass(maturity = MaturityLevel.EVOLVING) |
| 30 | +public class ErrorDetails { |
| 31 | + // error Message if any |
| 32 | + String errorMessage; |
| 33 | + // Readable description of the error |
| 34 | + String errorDescription; |
| 35 | + // Can the client retry for this type of error (Transient error=true, persistent error=false) |
| 36 | + boolean canRetryOnFailure; |
| 37 | + |
| 38 | + public static ErrorDetails create(Exception e, String errorDescription) { |
| 39 | + if (e == null) { |
| 40 | + return null; |
| 41 | + } |
| 42 | + |
| 43 | + return ErrorDetails.builder() |
| 44 | + .errorMessage(e.getMessage()) |
| 45 | + .errorDescription(errorDescription) |
| 46 | + .canRetryOnFailure(true) |
| 47 | + .build(); |
| 48 | + } |
| 49 | +} |
0 commit comments