/** * Renderiza el mensaje de error * * @param \Throwable $error Instancia de Throwable * * @return string */ protected function render(\Throwable $error) { $message = new ErrorMessage(); $details = ''; if ($this->displayErrorDetails) { $details = []; do { $details[] = ['type' => get_class($error), 'code' => $error->getCode(), 'message' => $error->getMessage(), 'file' => $error->getFile(), 'line' => $error->getLine(), 'trace' => explode("\n", $error->getTraceAsString())]; } while ($error = $error->getPrevious()); } $message->append('Resty Application Error', $details, 500); return json_encode($message, JSON_PRETTY_PRINT); }
/** * Renderiza el mensaje de error * * @param ServerRequestInterface $request Instancia de Request * @param array $methods Array de metodos http disponibles * * @return string */ protected function render(ServerRequestInterface $request, array $methods) { $message = new ErrorMessage(); $message->append('Method not allowed', 'Request => ' . $request->getMethod() . ":" . $request->getUri()->__toString() . '. Method not allowed. Must be one of ' . implode(", ", $methods), 405); return json_encode($message, JSON_PRETTY_PRINT); }
/** * Renderiza el mensaje de error * * @param ServerRequestInterface $request Instancia de Request * * @return string */ protected function render(ServerRequestInterface $request) { $message = new ErrorMessage(); $message->append('Page not found', 'Request => ' . $request->getMethod() . ":" . $request->getUri()->__toString(), 404); return json_encode($message, JSON_PRETTY_PRINT); }