This is an automated email from the ASF dual-hosted git repository. gortiz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push: new e35f43c151 Include the exception message in error response (#14395) e35f43c151 is described below commit e35f43c151bc0da540ad92324bb4771be509ae1b Author: Shounak kulkarni <shounakmk...@gmail.com> AuthorDate: Thu Nov 7 17:39:33 2024 +0530 Include the exception message in error response (#14395) --- .../controller/api/resources/PinotSchemaRestletResource.java | 10 +++++----- .../controller/api/resources/PinotTableRestletResource.java | 2 +- .../controller/api/resources/PinotTaskRestletResource.java | 4 ++-- .../controller/api/resources/PinotTenantRestletResource.java | 9 +++++---- .../controller/api/resources/PinotUpsertRestletResource.java | 2 +- .../controller/api/resources/TableConfigsRestletResource.java | 11 ++++++----- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java index eecfe63b6c..d2f997cf61 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java @@ -430,8 +430,8 @@ public class PinotSchemaRestletResource { throw new ControllerApplicationException(LOGGER, e.getMessage(), Response.Status.BAD_REQUEST, e); } catch (Exception e) { _controllerMetrics.addMeteredGlobalValue(ControllerMeter.CONTROLLER_SCHEMA_UPLOAD_ERROR, 1L); - throw new ControllerApplicationException(LOGGER, String.format("Failed to add new schema %s.", schemaName), - Response.Status.INTERNAL_SERVER_ERROR, e); + throw new ControllerApplicationException(LOGGER, String.format("Failed to add new schema %s. Reason: %s", + schemaName, e.getMessage()), Response.Status.INTERNAL_SERVER_ERROR, e); } } @@ -474,8 +474,8 @@ public class PinotSchemaRestletResource { Response.Status.NOT_FOUND, e); } catch (Exception e) { _controllerMetrics.addMeteredGlobalValue(ControllerMeter.CONTROLLER_SCHEMA_UPLOAD_ERROR, 1L); - throw new ControllerApplicationException(LOGGER, String.format("Failed to update schema %s", schemaName), - Response.Status.INTERNAL_SERVER_ERROR, e); + throw new ControllerApplicationException(LOGGER, String.format("Failed to update schema %s. Reason: %s", + schemaName, e.getMessage()), Response.Status.INTERNAL_SERVER_ERROR, e); } } @@ -520,7 +520,7 @@ public class PinotSchemaRestletResource { try { return JsonUtils.stringToObjectAndUnrecognizedProperties(schemaJsonString, Schema.class); } catch (Exception e) { - String msg = String.format("Invalid schema config json string: %s", schemaJsonString); + String msg = String.format("Invalid schema config json string: %s. Reason: %s", schemaJsonString, e.getMessage()); throw new ControllerApplicationException(LOGGER, msg, Response.Status.BAD_REQUEST, e); } } diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java index c8e072db86..0320e149d7 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java @@ -541,7 +541,7 @@ public class PinotTableRestletResource { tableConfigAndUnrecognizedProperties = JsonUtils.stringToObjectAndUnrecognizedProperties(tableConfigStr, TableConfig.class); } catch (IOException e) { - String msg = String.format("Invalid table config json string: %s", tableConfigStr); + String msg = String.format("Invalid table config json string: %s. Reason: %s", tableConfigStr, e.getMessage()); throw new ControllerApplicationException(LOGGER, msg, Response.Status.BAD_REQUEST, e); } TableConfig tableConfig = tableConfigAndUnrecognizedProperties.getLeft(); diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java index 9cfcbc3a06..9b8df75576 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java @@ -236,8 +236,8 @@ public class PinotTaskRestletResource { return _pinotHelixTaskResourceManager.getTaskMetadataByTable(taskType, tableNameWithType); } catch (JsonProcessingException e) { throw new ControllerApplicationException(LOGGER, String - .format("Failed to format task metadata into Json for task type: %s from table: %s", taskType, - tableNameWithType), Response.Status.INTERNAL_SERVER_ERROR, e); + .format("Failed to format task metadata into Json for task type: %s from table: %s. Reason: %s", taskType, + tableNameWithType, e.getMessage()), Response.Status.INTERNAL_SERVER_ERROR, e); } } diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTenantRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTenantRestletResource.java index 7420c6a748..525ba828f6 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTenantRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTenantRestletResource.java @@ -369,8 +369,8 @@ public class PinotTenantRestletResource { InstancePartitionsUtils.persistInstancePartitions(_pinotHelixResourceManager.getPropertyStore(), instancePartitions); } catch (Exception e) { - throw new ControllerApplicationException(LOGGER, "Caught Exception while persisting the instance partitions", - Response.Status.INTERNAL_SERVER_ERROR, e); + throw new ControllerApplicationException(LOGGER, "Caught Exception while persisting the instance partitions. " + + "Reason: " + e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR, e); } } @@ -605,7 +605,7 @@ public class PinotTenantRestletResource { } catch (Exception e) { _controllerMetrics.addMeteredGlobalValue(ControllerMeter.CONTROLLER_INSTANCE_POST_ERROR, 1L); throw new ControllerApplicationException(LOGGER, - String.format("Error during %s operation for instance: %s", type, instance), + String.format("Error during %s operation for instance: %s. Reason: %s", type, instance, e.getMessage()), Response.Status.INTERNAL_SERVER_ERROR, e); } return instanceResult.toString(); @@ -661,7 +661,8 @@ public class PinotTenantRestletResource { return new SuccessResponse("Successfully deleted tenant " + tenantName); } _controllerMetrics.addMeteredGlobalValue(ControllerMeter.CONTROLLER_TABLE_TENANT_DELETE_ERROR, 1L); - throw new ControllerApplicationException(LOGGER, "Error deleting tenant", Response.Status.INTERNAL_SERVER_ERROR); + throw new ControllerApplicationException(LOGGER, "Error deleting tenant. Reason: " + res.getMessage(), + Response.Status.INTERNAL_SERVER_ERROR); } @POST diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotUpsertRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotUpsertRestletResource.java index 8173b35e6a..764da75881 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotUpsertRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotUpsertRestletResource.java @@ -112,7 +112,7 @@ public class PinotUpsertRestletResource { tableSchemaConfig = JsonUtils.stringToObject(tableSchemaConfigStr, TableAndSchemaConfig.class); } catch (IOException e) { throw new ControllerApplicationException(LOGGER, - String.format("Invalid TableSchemaConfigs json string: %s", tableSchemaConfigStr), + String.format("Invalid TableSchemaConfigs json string: %s. Reason: %s", tableSchemaConfigStr, e.getMessage()), Response.Status.BAD_REQUEST, e); } diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableConfigsRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableConfigsRestletResource.java index ea21f2ce46..df543614b9 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableConfigsRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableConfigsRestletResource.java @@ -247,8 +247,8 @@ public class TableConfigsRestletResource { } catch (Exception e) { _controllerMetrics.addMeteredGlobalValue(ControllerMeter.CONTROLLER_TABLE_ADD_ERROR, 1L); if (e instanceof InvalidTableConfigException) { - throw new ControllerApplicationException(LOGGER, String.format("Invalid TableConfigs: %s", rawTableName), - Response.Status.BAD_REQUEST, e); + throw new ControllerApplicationException(LOGGER, String.format("Invalid TableConfigs: %s. Reason: %s", + rawTableName, e.getMessage()), Response.Status.BAD_REQUEST, e); } else if (e instanceof TableAlreadyExistsException) { throw new ControllerApplicationException(LOGGER, e.getMessage(), Response.Status.CONFLICT, e); } else { @@ -333,8 +333,8 @@ public class TableConfigsRestletResource { "'tableName' in TableConfigs: %s must match provided tableName: %s", tableConfigs.getTableName(), tableName); tableConfigs.setTableName(tableName); } catch (Exception e) { - throw new ControllerApplicationException(LOGGER, String.format("Invalid TableConfigs: %s", tableName), - Response.Status.BAD_REQUEST, e); + throw new ControllerApplicationException(LOGGER, String.format("Invalid TableConfigs: %s. Reason: %s", tableName, + e.getMessage()), Response.Status.BAD_REQUEST, e); } if (!_pinotHelixResourceManager.hasOfflineTable(tableName) && !_pinotHelixResourceManager.hasRealtimeTable( @@ -406,7 +406,8 @@ public class TableConfigsRestletResource { JsonUtils.stringToObjectAndUnrecognizedProperties(tableConfigsStr, TableConfigs.class); } catch (IOException e) { throw new ControllerApplicationException(LOGGER, - String.format("Invalid TableConfigs json string: %s", tableConfigsStr), Response.Status.BAD_REQUEST, e); + String.format("Invalid TableConfigs json string: %s. Reason: %s", tableConfigsStr, e.getMessage()), + Response.Status.BAD_REQUEST, e); } String databaseName = DatabaseUtils.extractDatabaseFromHttpHeaders(httpHeaders); TableConfigs tableConfigs = tableConfigsAndUnrecognizedProps.getLeft(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org