Skip to content
Snippets Groups Projects
Commit bd5179ea authored by Georgi's avatar Georgi
Browse files

[BUGFIX] More user-friendly error handling

parent 3f76259c
No related branches found
Tags 8.1.1
No related merge requests found
...@@ -172,9 +172,9 @@ class YoutubeController extends ActionController { ...@@ -172,9 +172,9 @@ class YoutubeController extends ActionController {
return $this->returnNoVideosFoundResponse($debugOutput); return $this->returnNoVideosFoundResponse($debugOutput);
} }
throw $exception; return $this->displayException($exception);
} catch (Exception $exception) { } catch (Exception $exception) {
return $this->htmlResponse('<div style="color: red;">' . $exception->getMessage() . '</div>'); return $this->displayException($exception);
} }
if (count($jsonArray['items']) < 1) { if (count($jsonArray['items']) < 1) {
...@@ -362,4 +362,14 @@ class YoutubeController extends ActionController { ...@@ -362,4 +362,14 @@ class YoutubeController extends ActionController {
); );
return $this->htmlResponse(); return $this->htmlResponse();
} }
/**
* Displays an error message and exception
*
* @param InvalidArgumentException|Exception $exception
* @return ResponseInterface
*/
public function displayException(InvalidArgumentException|Exception $exception): ResponseInterface {
return $this->htmlResponse('<div style="color: red;">' . $exception->getMessage() . '</div>');
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment