Skip to content

Commit dd67923

Browse files
committedNov 22, 2012
Fix #15199: Update json api error format
1 parent 4c6e6f0 commit dd67923

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎core/json_api.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ function json_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
6363
}
6464
}
6565

66+
$t_error_code = ERROR_GENERIC; // default
67+
6668
# build an appropriate error string
6769
switch( $p_type ) {
6870
case E_WARNING:
@@ -75,10 +77,12 @@ function json_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
7577
break;
7678
case E_USER_ERROR:
7779
$t_error_type = "APPLICATION ERROR #$p_error";
80+
$t_error_code = $p_error;
7881
$t_error_description = error_string( $p_error );
7982
break;
8083
case E_USER_WARNING:
8184
$t_error_type = "APPLICATION WARNING #$p_error";
85+
$t_error_code = $p_error;
8286
$t_error_description = error_string( $p_error );
8387
break;
8488
case E_USER_NOTICE:
@@ -94,7 +98,11 @@ function json_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
9498

9599
json_output_raw(array(
96100
'status' => 'ERROR',
97-
'type' => $t_error_type,
101+
'error' => array(
102+
'code' => $t_error_code,
103+
'type' => $t_error_type,
104+
'message' => $t_error_description
105+
),
98106
'contents' => $t_error_description
99107
));
100108
}

0 commit comments

Comments
 (0)
Please sign in to comment.