GetDKAN / RootedJsonData

Access and modify JSON-based data objects while enforcing JSON Schema
GNU General Public License v3.0
1 stars 0 forks source link

Improve exception handling #3

Closed dafeder closed 3 years ago

dafeder commented 3 years ago

Improves exception handling throughout the RootedJsonData class:

  1. When basic json_decode() fails, throws an \InvalidArgumentException() (better practice than simple \Exception) and includes the json_decode error message.
  2. Passes the actual Opis\JsonSchema\Exception\InvalidSchemaException() when a schema is rejected rather than catching and replacing with simple \Exception.
  3. Provides a new ValidationException() class to catch validation errors from Opis and pass them along in a validationResult property.

There is an argument to be made that we should not be so reliant on exceptions and other classes from a dependency (Opis and JsonPath) but the reality is that our library is pretty thin, we're just providing integration between these two libraries anyway