mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-09 01:23:10 +03:00
Log json_exception messages so that we can later troubleshoot them
This commit is contained in:
parent
540af17e4f
commit
00bb543c93
1 changed files with 15 additions and 14 deletions
|
@ -26,7 +26,7 @@ if (!function_exists('request')) {
|
|||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
function request(string $key = null, $default = null)
|
||||
function request(string $key = null, $default = null): mixed
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = &get_instance();
|
||||
|
@ -57,7 +57,7 @@ if (!function_exists('response')) {
|
|||
* @param int $status
|
||||
* @param array $headers
|
||||
*/
|
||||
function response(string $content = '', int $status = 200, array $headers = [])
|
||||
function response(string $content = '', int $status = 200, array $headers = []): void
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = &get_instance();
|
||||
|
@ -78,7 +78,7 @@ if (!function_exists('response')) {
|
|||
* @param int $status
|
||||
* @param array $headers
|
||||
*/
|
||||
function response(string $content = '', int $status = 200, array $headers = [])
|
||||
function response(string $content = '', int $status = 200, array $headers = []): void
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = &get_instance();
|
||||
|
@ -105,7 +105,7 @@ if (!function_exists('json_response')) {
|
|||
* @param int $status
|
||||
* @param array $headers
|
||||
*/
|
||||
function json_response(array $content = [], int $status = 200, array $headers = [])
|
||||
function json_response(array $content = [], int $status = 200, array $headers = []): void
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = &get_instance();
|
||||
|
@ -131,16 +131,17 @@ if (!function_exists('json_exception')) {
|
|||
*
|
||||
* @param Throwable $e
|
||||
*/
|
||||
function json_exception(Throwable $e)
|
||||
function json_exception(Throwable $e): void
|
||||
{
|
||||
json_response(
|
||||
[
|
||||
'success' => false,
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => config('debug') ? $e->getTrace() : [],
|
||||
],
|
||||
500,
|
||||
);
|
||||
$response = [
|
||||
'success' => false,
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => config('debug') ? $e->getTrace() : [],
|
||||
];
|
||||
|
||||
log_message('error', 'JSON exception: ' . json_encode($response));
|
||||
|
||||
json_response($response, 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +159,7 @@ if (!function_exists('abort')) {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function abort(int $code, string $message = '', array $headers = [])
|
||||
function abort(int $code, string $message = '', array $headers = []): void
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = &get_instance();
|
||||
|
|
Loading…
Reference in a new issue