Classify the Plugin errors to Action and Datasource configuration issues (#7095)
This commit is contained in:
parent
93ce03c765
commit
a4434872b0
|
|
@ -9,7 +9,8 @@ import java.text.MessageFormat;
|
|||
@Getter
|
||||
public enum AppsmithPluginError {
|
||||
|
||||
PLUGIN_ERROR(500, 5000, "{0}", AppsmithErrorAction.LOG_EXTERNALLY, "Query execution error", ErrorType.INTERNAL_ERROR),
|
||||
PLUGIN_ERROR(500, 5000, "{0}",
|
||||
AppsmithErrorAction.LOG_EXTERNALLY, "Query execution error", ErrorType.INTERNAL_ERROR),
|
||||
PLUGIN_GET_STRUCTURE_ERROR(500, 5001, "{0}", AppsmithErrorAction.DEFAULT, "Failed to get datasource " +
|
||||
"structure", ErrorType.INTERNAL_ERROR),
|
||||
PLUGIN_QUERY_TIMEOUT_ERROR(504, 5002, "{0} timed out in {1} milliseconds. " +
|
||||
|
|
@ -21,8 +22,9 @@ public enum AppsmithPluginError {
|
|||
PLUGIN_GET_STRUCTURE_TIMEOUT_ERROR(504, 5003, "{0}", AppsmithErrorAction.LOG_EXTERNALLY, "Timed out when fetching" +
|
||||
" datasource structure", ErrorType.CONNECTIVITY_ERROR),
|
||||
PLUGIN_DATASOURCE_ARGUMENT_ERROR(500, 5004, "{0}", AppsmithErrorAction.DEFAULT, "Datasource configuration is " +
|
||||
"invalid", ErrorType.ARGUMENT_ERROR),
|
||||
PLUGIN_EXECUTE_ARGUMENT_ERROR(500, 5005, "{0}", AppsmithErrorAction.DEFAULT, "Query configuration is invalid", ErrorType.ARGUMENT_ERROR),
|
||||
"invalid", ErrorType.DATASOURCE_CONFIGURATION_ERROR),
|
||||
PLUGIN_EXECUTE_ARGUMENT_ERROR(500, 5005, "{0}", AppsmithErrorAction.DEFAULT,
|
||||
"Query configuration is invalid", ErrorType.ACTION_CONFIGURATION_ERROR),
|
||||
PLUGIN_JSON_PARSE_ERROR(500, 5006, "Plugin failed to parse JSON \"{0}\" with error: {1}",
|
||||
AppsmithErrorAction.DEFAULT, "Invalid JSON found", ErrorType.INTERNAL_ERROR),
|
||||
PLUGIN_DATASOURCE_TEST_GENERIC_ERROR(500, 5007, "Plugin failed to test with the given configuration. Please reach out to Appsmith customer support to report this",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ public enum ErrorType {
|
|||
CONNECTIVITY_ERROR,
|
||||
AUTHENTICATION_ERROR,
|
||||
BAD_REQUEST,
|
||||
INTERNAL_ERROR
|
||||
INTERNAL_ERROR,
|
||||
ACTION_CONFIGURATION_ERROR
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,19 +37,19 @@ public class AppendMethod implements Method {
|
|||
@Override
|
||||
public boolean validateMethodRequest(MethodConfig methodConfig) {
|
||||
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Spreadsheet Url");
|
||||
}
|
||||
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Sheet name");
|
||||
}
|
||||
if (methodConfig.getTableHeaderIndex() != null && !methodConfig.getTableHeaderIndex().isBlank()) {
|
||||
try {
|
||||
if (Integer.parseInt(methodConfig.getTableHeaderIndex()) <= 0) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected value for table header index. Please use a number starting from 1");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected format for table header index. Please use a number starting from 1");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,19 +38,19 @@ public class BulkAppendMethod implements Method {
|
|||
@Override
|
||||
public boolean validateMethodRequest(MethodConfig methodConfig) {
|
||||
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Spreadsheet Url");
|
||||
}
|
||||
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Sheet name");
|
||||
}
|
||||
if (methodConfig.getTableHeaderIndex() != null && !methodConfig.getTableHeaderIndex().isBlank()) {
|
||||
try {
|
||||
if (Integer.parseInt(methodConfig.getTableHeaderIndex()) <= 0) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected value for table header index. Please use a number starting from 1");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected format for table header index. Please use a number starting from 1");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,19 +38,19 @@ public class BulkUpdateMethod implements Method {
|
|||
@Override
|
||||
public boolean validateMethodRequest(MethodConfig methodConfig) {
|
||||
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Spreadsheet Url");
|
||||
}
|
||||
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Sheet name");
|
||||
}
|
||||
if (methodConfig.getTableHeaderIndex() != null && !methodConfig.getTableHeaderIndex().isBlank()) {
|
||||
try {
|
||||
if (Integer.parseInt(methodConfig.getTableHeaderIndex()) <= 0) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected value for table header index. Please use a number starting from 1");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected format for table header index. Please use a number starting from 1");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ public class ClearMethod implements Method {
|
|||
@Override
|
||||
public boolean validateMethodRequest(MethodConfig methodConfig) {
|
||||
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Spreadsheet Url");
|
||||
}
|
||||
if (methodConfig.getSpreadsheetRange() == null || methodConfig.getSpreadsheetRange().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Data Range");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Data Range");
|
||||
}
|
||||
return true;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ public class CopyMethod implements Method {
|
|||
@Override
|
||||
public boolean validateMethodRequest(MethodConfig methodConfig) {
|
||||
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Spreadsheet Url");
|
||||
}
|
||||
if (methodConfig.getSheetId() == null || methodConfig.getSheetId().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet Id");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Sheet Id");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,33 +30,33 @@ public class DeleteRowMethod implements Method {
|
|||
@Override
|
||||
public boolean validateMethodRequest(MethodConfig methodConfig) {
|
||||
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Spreadsheet Url");
|
||||
}
|
||||
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Sheet name");
|
||||
}
|
||||
if (methodConfig.getRowIndex() == null || methodConfig.getRowIndex().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Row index");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Row index");
|
||||
}
|
||||
int rowIndex = 0;
|
||||
try {
|
||||
rowIndex = Integer.parseInt(methodConfig.getRowIndex());
|
||||
if (rowIndex < 0) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected value for row index. Please use a number starting from 0");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected format for row index. Please use a number starting from 0");
|
||||
}
|
||||
if (methodConfig.getTableHeaderIndex() != null && !methodConfig.getTableHeaderIndex().isBlank()) {
|
||||
try {
|
||||
if (Integer.parseInt(methodConfig.getTableHeaderIndex()) <= 0) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected value for table header index. Please use a number starting from 1");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected format for table header index. Please use a number starting from 1");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,19 +35,19 @@ public class UpdateMethod implements Method {
|
|||
@Override
|
||||
public boolean validateMethodRequest(MethodConfig methodConfig) {
|
||||
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Spreadsheet Url");
|
||||
}
|
||||
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field Sheet name");
|
||||
}
|
||||
if (methodConfig.getTableHeaderIndex() != null && !methodConfig.getTableHeaderIndex().isBlank()) {
|
||||
try {
|
||||
if (Integer.parseInt(methodConfig.getTableHeaderIndex()) <= 0) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected value for table header index. Please use a number starting from 1");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR,
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
|
||||
"Unexpected format for table header index. Please use a number starting from 1");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@ public class RowObject {
|
|||
|
||||
public RowObject initialize() {
|
||||
if (this.rowIndex == null) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field row index.");
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Missing required field row index.");
|
||||
}
|
||||
try {
|
||||
this.currentRowIndex = Integer.parseInt(this.rowIndex);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Unable to parse row index: " + this.rowIndex);
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Unable to parse row index: " + this.rowIndex);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ public class RestApiPlugin extends BasePlugin {
|
|||
ActionExecutionRequest actionExecutionRequest =
|
||||
RequestCaptureFilter.populateRequestFields(actionConfiguration, null, insertedParams, objectMapper);
|
||||
actionExecutionRequest.setUrl(url);
|
||||
errorResult.setBody(AppsmithPluginError.PLUGIN_ERROR.getMessage(e));
|
||||
errorResult.setBody(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR.getMessage(e));
|
||||
errorResult.setRequest(actionExecutionRequest);
|
||||
return Mono.just(errorResult);
|
||||
}
|
||||
|
|
@ -242,7 +242,7 @@ public class RestApiPlugin extends BasePlugin {
|
|||
RequestCaptureFilter.populateRequestFields(actionConfiguration, uri, insertedParams, objectMapper);
|
||||
|
||||
if (httpMethod == null) {
|
||||
errorResult.setBody(AppsmithPluginError.PLUGIN_ERROR.getMessage("HTTPMethod must be set."));
|
||||
errorResult.setBody(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR.getMessage("HTTPMethod must be set."));
|
||||
errorResult.setRequest(actionExecutionRequest);
|
||||
return Mono.just(errorResult);
|
||||
}
|
||||
|
|
@ -264,7 +264,7 @@ public class RestApiPlugin extends BasePlugin {
|
|||
// Check for content type
|
||||
final String contentTypeError = verifyContentType(actionConfiguration.getHeaders());
|
||||
if (contentTypeError != null) {
|
||||
errorResult.setBody(AppsmithPluginError.PLUGIN_ERROR.getMessage("Invalid value for Content-Type."));
|
||||
errorResult.setBody(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR.getMessage("Invalid value for Content-Type."));
|
||||
errorResult.setRequest(actionExecutionRequest);
|
||||
return Mono.just(errorResult);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user