@@ -35,6 +35,13 @@ class JAPI implements LoggerAwareInterface
35
35
36
36
use HasLogger;
37
37
38
+ /**
39
+ * Should we expose detailed error information in responses?
40
+ *
41
+ * @var bool
42
+ */
43
+ private $ bol_expose_errors = false ;
44
+
38
45
/**
39
46
* Hook up the shutdown function so we always send nice JSON error responses
40
47
*/
@@ -93,8 +100,6 @@ public function timeToDie()
93
100
/**
94
101
* Whatever went wrong, let 'em have it in JSON over HTTP
95
102
*
96
- * @todo Environment or LIVE check for extended error
97
- *
98
103
* @param \Exception $obj_error
99
104
* @param int $int_code
100
105
*/
@@ -105,7 +110,7 @@ protected function jsonError(\Exception $obj_error, $int_code)
105
110
'msg ' => ($ obj_error instanceof \ErrorException ? 'Internal Error ' : 'Exception ' )
106
111
];
107
112
$ str_log_message = get_class ($ obj_error ) . ': ' . $ obj_error ->getMessage ();
108
- if (TRUE ) { // @todo Environment or LIVE check
113
+ if ($ this -> bol_expose_errors ) {
109
114
$ arr_response ['detail ' ] = $ str_log_message ;
110
115
}
111
116
if ($ int_code < 400 || $ int_code > 505 ) {
@@ -129,4 +134,14 @@ protected function sendResponse($response, $http_code = 200)
129
134
echo json_encode ($ response );
130
135
}
131
136
137
+ /**
138
+ * Tell JAPI to expose error detail, or not!
139
+ *
140
+ * @param bool $bol_expose
141
+ */
142
+ public function exposeErrorDetail ($ bol_expose = true )
143
+ {
144
+ $ this ->bol_expose_errors = $ bol_expose ;
145
+ }
146
+
132
147
}
0 commit comments