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_messageskey.- when
display_exceptionsview configuration setting enabled, stack traces included viatrace,exception_stackproperties.
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
Post a Comment