Esempio n. 1
0
 /**
  * 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)
 {
     $sysLog = SystemLog::getInstance();
     if ($sysLog->debugging()) {
         try {
             $log = SystemLog::getInstance()->getLog();
             $log->addError("Exception", ["message" => $e->getMessage()]);
         } catch (Exception $exception) {
             return response()->json(["error" => true, "type" => get_class($e), "message" => $exception->getMessage()], 500);
         }
     }
     if ($e instanceof \PDOException) {
         return response()->json(['error' => true, 'type' => 'PDOException', 'message' => $e->getMessage()], 500);
     }
     if ($e instanceof \InvalidArgumentException) {
         return response()->json(['error' => true, 'type' => 'InvalidArgumentException', 'message' => $e->getMessage()], 500);
     }
     if ($e instanceof \UnexpectedValueException) {
         return response()->json(['error' => true, 'type' => 'UnexpectedValueException', 'message' => $e->getMessage()], 400);
     }
     // if ($e instanceof ModelNotFoundException) {
     //     $e = new NotFoundHttpException($e->getMessage(), $e);
     // }
     return response()->json(["error" => true, "type" => get_class($e), "message" => "Error desconocido"], 500);
     // return parent::render($request, $e);
 }
Esempio n. 2
0
 /**
  * Test para agregar una entrada al log.
  */
 public function testAddInfo()
 {
     $log = SystemLog::getInstance()->getLog();
     $log->addError('Test', ['message' => "Este es un test"]);
 }