001/** 002 * Copyright (C) 2006-2025 Talend Inc. - www.talend.com 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.talend.sdk.component.api.exception; 017 018import javax.json.bind.annotation.JsonbCreator; 019import javax.json.bind.annotation.JsonbPropertyOrder; 020 021import lombok.Data; 022import lombok.EqualsAndHashCode; 023 024/** 025 * This class is dedicated to Studio's guess schema feature. 026 * It has the same goal as ComponentException except that you can specify an action to execute in some cases. 027 * 028 * If you don't need such feature, just use ComponentException. 029 * 030 * See me TCOMP-2342 for more details. 031 */ 032@Data 033@EqualsAndHashCode(callSuper = true) 034@JsonbPropertyOrder({ "localizedMessage", "message", "stackTrace", "suppressed", "possibleHandleErrorWith" }) 035public class DiscoverSchemaException extends RuntimeException { 036 037 public enum HandleErrorWith { 038 /** 039 * default case 040 */ 041 EXCEPTION, 042 /** 043 * unhandled. 044 */ 045 SILENT, 046 /** 047 * unhandled. 048 */ 049 RETRY, 050 /** 051 * Potentially execute a mock job in studio. 052 * Will ask user's validation before executing. 053 * When specifying this option, developer should be sure that no side effect can be generated by connector. 054 */ 055 EXECUTE_MOCK_JOB, 056 /** 057 * Will execute a lifecycle through framework using only configuration. 058 * This won't query for any user input. 059 * When specifying this option, developer should be sure that no side effect can be generated by connector. 060 */ 061 EXECUTE_LIFECYCLE; 062 } 063 064 private HandleErrorWith possibleHandleErrorWith = HandleErrorWith.EXCEPTION; 065 066 public DiscoverSchemaException(final ComponentException e) { 067 super(e.getOriginalMessage(), e.getCause()); 068 } 069 070 public DiscoverSchemaException(final ComponentException e, final HandleErrorWith handling) { 071 super(e.getOriginalMessage(), e.getCause()); 072 setPossibleHandleErrorWith(handling); 073 } 074 075 public DiscoverSchemaException(final String message, final HandleErrorWith handling) { 076 super(message); 077 setPossibleHandleErrorWith(handling); 078 } 079 080 @JsonbCreator 081 public DiscoverSchemaException(final String message, final StackTraceElement[] stackTrace, 082 final HandleErrorWith handling) { 083 super(message); 084 setStackTrace(stackTrace); 085 setPossibleHandleErrorWith(handling); 086 } 087 088}