error handling - How to use validation_messages and display_exceptions in Apigility? -


from apigility documentation (error reporting):

the api problem specification allows compose other additional fields feel further clarify problem , why occurred. apigility uses fact provide more information in several ways:

  • validation error messages reported via validation_messages key.
  • when display_exceptions view configuration setting enabled, stack traces included via trace , exception_stack properties.

i don't understand part of docu. purpose , how use settings validation_messages , display_exceptions?

the display_exceptions setting zf2's view manager (see docs here). turning on cause apigiltiy include stack trace error response.

in apigility validation_messages key population handled automatically. configure input filter validates incoming data payload , if input filter fails error messages returns automatically injected api response under validation_messages key. functionality provided module zf-content-validation. can "do yourself" returning apiproblemresponse resource so:

return new apiproblemresponse(     new apiproblem(422, 'failed validation', null, null, array(         'validation_messages' => [ /* array of messages */ ]     )) ); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -