cphalcon: Phalcon 3.3 Micro error handler
Expected and Actual Behavior
The Micro Application error handler isn’t working properly on the latest version of Phalcon. The exception isn’t caught by the handler.
Expected output
{"code":401,"status":"error","message":"Invalid email or password."}
Actual output
Script to reproduce
<?php
$app = new Phalcon\Mvc\Micro();
$app->get(
'/',
function () {
throw new \Exception('Invalid email or password.', 401);
}
);
$app->error(
function ($exception) {
echo json_encode(
[
'code' => $exception->getCode(),
'status' => 'error',
'message' => $exception->getMessage(),
]
);
}
);
$app->handle();
Details
- Phalcon version: 3.3
- PHP Version: 7.1 & 7.2
- Operating System: macOS & Ubuntu 16.04
- Installation type: Installing via package manager
- Server: Nginx & Apache
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (9 by maintainers)
Not on the same function! You need to return false or response object in $app->error() handler
I don’t know, ask @niden xD
You can just disable the printing of PHP error in you php.ini. That I will always recommend on a production server anyway.