Skip to content

Commit

Permalink
Fix #15199: Update json api error format
Browse files Browse the repository at this point in the history
  • Loading branch information
rombert committed Nov 22, 2012
1 parent 4c6e6f0 commit dd67923
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/json_api.php
Expand Up @@ -63,6 +63,8 @@ function json_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
}
}

$t_error_code = ERROR_GENERIC; // default

# build an appropriate error string
switch( $p_type ) {
case E_WARNING:
Expand All @@ -75,10 +77,12 @@ function json_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
break;
case E_USER_ERROR:
$t_error_type = "APPLICATION ERROR #$p_error";
$t_error_code = $p_error;
$t_error_description = error_string( $p_error );
break;
case E_USER_WARNING:
$t_error_type = "APPLICATION WARNING #$p_error";
$t_error_code = $p_error;
$t_error_description = error_string( $p_error );
break;
case E_USER_NOTICE:
Expand All @@ -94,7 +98,11 @@ function json_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {

json_output_raw(array(
'status' => 'ERROR',
'type' => $t_error_type,
'error' => array(
'code' => $t_error_code,
'type' => $t_error_type,
'message' => $t_error_description
),
'contents' => $t_error_description
));
}
Expand Down

0 comments on commit dd67923

Please sign in to comment.