{"id":15188333,"url":"https://github.com/bearcodi/laravel-exception-handling-fun","last_synced_at":"2026-02-14T21:02:41.904Z","repository":{"id":72772273,"uuid":"197512045","full_name":"bearcodi/laravel-exception-handling-fun","owner":"bearcodi","description":"Laravel example project playing around with recording exceptions to database and custom responses.","archived":false,"fork":false,"pushed_at":"2019-10-30T20:36:19.000Z","size":168,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T05:06:43.002Z","etag":null,"topics":["example-code","laravel","laravel54","php7"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bearcodi.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-18T04:35:12.000Z","updated_at":"2019-07-18T12:46:13.000Z","dependencies_parsed_at":"2023-02-28T00:01:47.831Z","dependency_job_id":null,"html_url":"https://github.com/bearcodi/laravel-exception-handling-fun","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"94b009bc31e2309e140e8dfb0bc77dd655ed0d13"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bearcodi/laravel-exception-handling-fun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearcodi%2Flaravel-exception-handling-fun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearcodi%2Flaravel-exception-handling-fun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearcodi%2Flaravel-exception-handling-fun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearcodi%2Flaravel-exception-handling-fun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bearcodi","download_url":"https://codeload.github.com/bearcodi/laravel-exception-handling-fun/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearcodi%2Flaravel-exception-handling-fun/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29455601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T15:52:44.973Z","status":"ssl_error","status_checked_at":"2026-02-14T15:52:11.208Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example-code","laravel","laravel54","php7"],"created_at":"2024-09-27T19:03:39.652Z","updated_at":"2026-02-14T21:02:41.882Z","avatar_url":"https://github.com/bearcodi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Example application for custom Exception reporting and rendering\n\n\u003e This was done using Laravel 5.4 but is easily portable to newer versions.\n\nIn a default Laravel install you have access to the [`App\\Exceptions\\Handler`](app/Exceptions/Handler.php) class.\n\nThis class provides two methods `report()` and `render()` that will allow you to add any custom reporting and rendering logic easily without the need for 3rd party packages.\n\nThis is an exercise to scratch an itch and to respond to a [Laracasts thread](https://laracasts.com/discuss/channels/laravel/saving-errors-to-db-custom-error-messages), feel free to use it as a jumping point for something magical!!!\n\n\u003e See for more information: https://laravel.com/docs/5.4/errors#the-exception-handler\n\n## Lets be explicit!\n\nMaybe recording every exception might be excessive, or you only want to record exceptions specific actions, the idea is to only record exceptions that we explicitly throw.\n\nWe create a custom exception class [`App\\Exceptions\\RecordableException`](app/Exceptions/RecordableException.php) that we throw when we want to record an error.\n\nThen within the [`App\\Exceptions\\Handler`](app/Exceptions/Handler.php) class, we conditionally check for our custom exception and perform our recording and rending of our custom view.\n\nAll other exceptions will still go through to Laravel to deal with.\n\nYou can wrap areas of your application execution when you are unsure of what type of exception is being thrown in a `try/catch` and then throw a new instance of your custom exception class accordingly.\n\n## Catch all approach\n\nIf you want to catch all the exceptions that Laravel throws according to the [`App\\Exceptions\\Handler`](app/Exceptions/Handler.php), then remove the conditional statements checking for your custom exception class.\n\n## Further ideas\n\nIf you were to take this approach, it might be a good idea to maybe create a job that would create the errors, that way you could offload it to a queue and not potentially slow down the user experience and consume resources if your app all of a sudden fires of a bucket load of exceptions.\n\nYou could also use [Laravel Scout](https://laravel.com/docs/5.4/scout) to index your exceptions so you could get some kickass reporting/filtering without heavy lifting.\n\n## Installation\n\nSimple as cloning the repository and running composer install.\n\nThe [`composer.json`](compser.json) file has been changed to:\n - Ceate your `.env` file\n - Generate your `APP_KEY`\n - Create the sqlite database at `database/database.sqlite` (The [`.env.example`](.env.example) file is adjusted to default to `sqlite` for its connection)\n\n\nThen you can run `php artisan migrate` and `php artisan serve` and your good to go.\n\nThe homepage has links to throw exceptions and view the recorded errors.\n\n## Classes that make this happen\n\nClass | Purpose\n:-   | :-  \n[`App\\Error`](app/Error.php) | The Eloquent model for storing exceptions.\n[`App\\Exceptions\\RecordableException`](app/Exceptions/RecordableException.php) | Our custom exception for filtering which exceptions to record.\n[`App\\Exceptions\\Handle`](app/Exceptions/Handler.php) | This file is where the magic happens!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbearcodi%2Flaravel-exception-handling-fun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbearcodi%2Flaravel-exception-handling-fun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbearcodi%2Flaravel-exception-handling-fun/lists"}