/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if ($e instanceof QueryException) { Log::emergency($e->getMessage()); return response()->json(["Houve um erro interno no servidor."], 500); } return parent::render($request, $e); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { try { $task = Task::findOrFail($id); $task->delete(); return response()->json(['destroy' => true]); } catch (Exception $e) { Log::emergency('TaskAPIController::destroy can not destroy task', ['task_id' => $id]); return response()->json(['destroy' => true], 500); } }
/** * System is unusable. * * @param string $message * @param array $context * * @return bool */ public function emergency($message, array $context = []) { return Log::emergency($message, $context); }
/** * @param $data * @param array $contextualData * @param array $location */ public static function emergency($data, array $location = [], array $contextualData = []) { $msg = self::renderMessage($data, $location); /** @noinspection PhpUndefinedMethodInspection */ BaseLog::emergency($msg, $contextualData); }