public static function gerarLogException(\Exception $ex) { $msg = " - " . $ex->getMessage(); $msg .= " [Arquivo: " . $ex->getFile(); $msg .= " - Linha: " . $ex->getLine() . " ]"; return $msg; }
public function __invoke(Request $request, Response $response, \Exception $exception) { $context = ['file' => $exception->getFile(), 'line' => $exception->getLine(), 'code' => $exception->getCode()]; $msg = $exception->getMessage(); $this->logger->critical($msg, $context); //return parent::__invoke($request, $response, $exception); $output = json_encode(['error' => $msg, 'code' => 500]); $body = new \Slim\Http\Body(fopen('php://temp', 'r+')); $body->write($output); return $response->withStatus(500)->withHeader('Content-type', 'application/json;charset=utf-8')->withBody($body); }
public function onError(ConnectionInterface $conn, \Exception $e) { echo "An error has occurred: {$e->getMessage()}\n"; $conn->close(); }