예제 #1
0
 public static function handleException(\Exception $exception, Request $request, LoggerInterface $logger = null, $prettyPrint = true, $debug = false, array $formats = null)
 {
     if (null !== $logger) {
         self::logException($logger, $exception);
     }
     $formats = $formats ?: ['json', 'xml'];
     $format = $request->getRequestFormat(null);
     if (!$format || !in_array($format, $formats)) {
         return;
     }
     return VndErrorResponse::fromException($exception, $prettyPrint, $debug);
 }
예제 #2
0
 /** @test */
 public function it_exposes_message_from_hal_exceptions_in_debug_mode()
 {
     $exception = new EmptyHalException('Message');
     $response = VndErrorResponse::fromException($exception, true, true);
     $this->assertJsonStringEqualsJsonString(json_encode(['message' => 'Message']), $response->getContent());
 }