Skip to content

wtf-php/json-api-errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WTF-PHP - Json-Api-Errors Middleware

Json-Api-Errors provides two middlewares (PSR-7 or PSR-15 compliant), which format exceptions and returns JSON:API compliant errors.

You can either use the Middleware to return an error when it first occurs, or you can add them to an error bag to handle multiple errors (e.g. validation errors).

When handling multiple errors, the response status code will be the most general code determined from the bag.

For example:

  • 404 error and a 422 error, then 400 will be returned
  • 500 error and a 400 error, then 500 will be returned

Features

  • Json:API compliant
  • Use middleware that meets your needs:
    • PSR-7 compatible middleware
    • PSR-15 compatible middleware
  • Single or multiple exception handling
  • Steer the level of error detail via a debug flag

Usage

Examples

How to start the examples:

Proof of Concepts

There are two Proof of Concepts, that showcase the usage of the middlewares:

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages