Skip to content

Commit

Permalink
Get a comment back to keep the intention of Exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dmikurube committed Sep 21, 2023
1 parent ba6d47b commit 3fa6872
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/org/embulk/parser/json/JsonParserPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ public void run(TaskSource taskSource, Schema schema, FileInput input, PageOutpu
throw new JsonRecordValidateException("A Json record doesn't have given 'JSON pointer to root'.");
}
} catch (JsonParseException e) {
/*
* When JsonParseException is thrown, it would be an error that
* the given JSON pointer doesn't match with the JSON object.
* We would return NULL when the pointer doesn't match, not throw Exception.
*
* NOTE: We may change the behavior.
* See: https://github.com/embulk/embulk/pull/1103#discussion_r255807991
*/
throw new JsonRecordValidateException("A Json record doesn't have given 'JSON pointer to root'.");
}
}
Expand Down Expand Up @@ -284,6 +292,14 @@ private void setValueWithCustomSchema(
.build(valueAsJsonString)
.readJsonValue();
} catch (final IOException ex) {
/*
* When JsonParseException is thrown, it would be an error that
* the given JSON pointer doesn't match with the JSON object.
* We would return NULL when the pointer doesn't match, not throw Exception.
*
* NOTE: We may change the behavior.
* See: https://github.com/embulk/embulk/pull/1103#discussion_r255807991
*/
throw new JsonParseException("Failed to parse JSON: " + valueAsJsonString, ex);
}
} else {
Expand Down

0 comments on commit 3fa6872

Please sign in to comment.