Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
AnourValar committed Mar 12, 2023
1 parent e845b72 commit cf72779
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Exceptions/HandlerRenderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public function render($request, Throwable $e)

if ($request->expectsJson()) {
$response->setData(['message' => ($e->getMessage() ?: 'Method Not Allowed.'), 'errors' => []]);
} else {
//abort(404);
}

}
Expand All @@ -88,25 +86,31 @@ public function render($request, Throwable $e)

// HttpException => verified
if ($e instanceof HttpException && $e->getMessage() == 'Your email address is not verified.') {

if ($request->expectsJson()) {
$response->setData(['message' => $e->getMessage(), 'errors' => []]);
}

}

// TokenMismatchException
if ($e instanceof TokenMismatchException) {

if ($request->expectsJson()) {
$response->setData(['message' => $e->getMessage(), 'errors' => []]);
}

}

// JsonEncodingException
if ($e instanceof JsonEncodingException) {

if ($request->expectsJson()) {
return response(['message' => 'Malformed UTF-8 characters, possibly incorrectly encoded.'], 400);
} else {
return response('Malformed UTF-8 characters, possibly incorrectly encoded.', 400);
}

}


Expand Down

0 comments on commit cf72779

Please sign in to comment.