| @@ 163-185 (lines=23) @@ | ||
| 160 | * |
|
| 161 | * @return string |
|
| 162 | */ |
|
| 163 | protected function renderJsonErrorMessage(\Exception $exception) |
|
| 164 | { |
|
| 165 | $error = [ |
|
| 166 | 'message' => 'Slim Application Error', |
|
| 167 | ]; |
|
| 168 | ||
| 169 | if ($this->displayErrorDetails) { |
|
| 170 | $error['exception'] = []; |
|
| 171 | ||
| 172 | do { |
|
| 173 | $error['exception'][] = [ |
|
| 174 | 'type' => get_class($exception), |
|
| 175 | 'code' => $exception->getCode(), |
|
| 176 | 'message' => $exception->getMessage(), |
|
| 177 | 'file' => $exception->getFile(), |
|
| 178 | 'line' => $exception->getLine(), |
|
| 179 | 'trace' => explode("\n", $exception->getTraceAsString()), |
|
| 180 | ]; |
|
| 181 | } while ($exception = $exception->getPrevious()); |
|
| 182 | } |
|
| 183 | ||
| 184 | return json_encode($error, JSON_PRETTY_PRINT); |
|
| 185 | } |
|
| 186 | ||
| 187 | /** |
|
| 188 | * Render XML error |
|
| @@ 144-166 (lines=23) @@ | ||
| 141 | * |
|
| 142 | * @return string |
|
| 143 | */ |
|
| 144 | protected function renderJsonErrorMessage(\Throwable $error) |
|
| 145 | { |
|
| 146 | $json = [ |
|
| 147 | 'message' => 'Slim Application Error', |
|
| 148 | ]; |
|
| 149 | ||
| 150 | if ($this->displayErrorDetails) { |
|
| 151 | $json['error'] = []; |
|
| 152 | ||
| 153 | do { |
|
| 154 | $json['error'][] = [ |
|
| 155 | 'type' => get_class($error), |
|
| 156 | 'code' => $error->getCode(), |
|
| 157 | 'message' => $error->getMessage(), |
|
| 158 | 'file' => $error->getFile(), |
|
| 159 | 'line' => $error->getLine(), |
|
| 160 | 'trace' => explode("\n", $error->getTraceAsString()), |
|
| 161 | ]; |
|
| 162 | } while ($error = $error->getPrevious()); |
|
| 163 | } |
|
| 164 | ||
| 165 | return json_encode($json, JSON_PRETTY_PRINT); |
|
| 166 | } |
|
| 167 | ||
| 168 | /** |
|
| 169 | * Render XML error |
|