withContentType(ContentType::HTML)->withBody(new Stream(jTraceEx($exception, null, true))); if ($exception->getCode() == 404) { return $response->withStatus(404); } else { return $response->withStatus($exception->getCode() == 0 ? 500 : $exception->getCode()); } } }