vvysotskyi commented on a change in pull request #2177:
URL: https://github.com/apache/drill/pull/2177#discussion_r579806322



##########
File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistryImpl.java
##########
@@ -510,6 +512,22 @@ public StoragePluginConfig decode(String json) throws 
PluginEncodingException {
       return context.mapper().reader()
           .forType(StoragePluginConfig.class)
           .readValue(json);
+    } catch (InvalidTypeIdException e) {
+      String helpfulDesc = e.getMessage();
+      // See also DeserializationContext#missingTypeIdException()
+      int _colonConcat = helpfulDesc.indexOf(": ");
+      if (_colonConcat > 0) {
+        helpfulDesc = helpfulDesc.substring(_colonConcat + 1, 
helpfulDesc.length());
+      }
+      throw new PluginEncodingException(helpfulDesc, e);
+    } catch (UnrecognizedPropertyException e) {
+      String helpfulDesc = e.getMessage();
+      // See also UnrecognizedPropertyException#from()
+      int _classConcat = helpfulDesc.indexOf(" (class ");
+      if (_classConcat > 0) {
+        helpfulDesc = helpfulDesc.substring(0, _classConcat);
+      }
+      throw new PluginEncodingException(helpfulDesc, e);

Review comment:
       I don't think that it is a good practice to parse error messages, the 
message format may be changed in a newer version of the library where it is 
thrown. Besides the error message format itself, the error may be wrapped into 
another one, so these catch blocks wouldn't work.
   
   I would recommend just adding to the required catch in the 
`StorageResources` code that simply calls
   `Throwables.getRootCause(e).getMessage()` if we want displaying detailed 
root cause.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to