Skip to content

ch06_error_handling

Daniel Samson edited this page Nov 9, 2022 · 4 revisions

The TeensyPHP router() function contains an error handler. Simply throw an exception or error with the corresponding code eg:

throw new \Error("Something went wrong", 500);

TeensyPHP in this case will output the following error with a status code of 500:

{
  "error": "Something went wrong"
}
Clone this wiki locally