rfc:json_throw_on_error

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:json_throw_on_error [2017/09/24 15:01] ajfrfc:json_throw_on_error [2017/09/24 15:02] – <php>JSON_THROW_ON_ERROR</php> ajf
Line 16: Line 16:
 <php>JsonException</php> would be a new class that subclasses <php>Exception</php>. <php>JsonException</php> would be a new class that subclasses <php>Exception</php>.
  
-Note that when given an invalid depth parameter, <php>json_decode()</php> outputs a warning and returns NULL. This behaviour is unaffected by JSON_THROW_ON_ERROR because it does not affect the global error state at present, has no corresponding error code to throw an exception with, and is not dependent on user input. Similarly, parameter parsing errors continue to produce warnings (when not in strict mode) because their error behaviour cannot be conditioned on the value of a parameter being parsed. Both can be caught by a user error handler that converts errors to exceptions.+Note that when given an invalid depth parameter, <php>json_decode()</php> outputs a warning and returns NULL. This behaviour is unaffected by <php>JSON_THROW_ON_ERROR</php> because it does not affect the global error state at present, has no corresponding error code to throw an exception with, and is not dependent on user input. Similarly, parameter parsing errors continue to produce warnings (when not in strict mode) because their error behaviour cannot be conditioned on the value of a parameter being parsed. Both can be caught by a user error handler that converts errors to exceptions.
  
 At the present time, there would be no change to the default error behaviour. It would be worthwhile considering whether to eventually slowly deprecate not using <php>JSON_THROW_ON_ERROR</php> and then change the default behaviour, but this RFC does not do this. At the present time, there would be no change to the default error behaviour. It would be worthwhile considering whether to eventually slowly deprecate not using <php>JSON_THROW_ON_ERROR</php> and then change the default behaviour, but this RFC does not do this.
Line 68: Line 68:
 ===== Changelog ===== ===== Changelog =====
  
-  * v1.0.2 - change behaviour to leave global error flag untouched, rather than clearing it; note depth error+  * v1.0.2 - change behaviour to leave global error flag untouched, rather than clearing it; note depth, param-parsing errors
   * v1.0.1 - cover details of the patch not previously mentioned   * v1.0.1 - cover details of the patch not previously mentioned
   * v1.0 - initial version   * v1.0 - initial version
rfc/json_throw_on_error.txt · Last modified: 2017/10/22 18:44 by ajf