{"id":15638105,"url":"https://github.com/mechero/spring-boot-rest-exceptions","last_synced_at":"2025-04-30T06:22:56.116Z","repository":{"id":90103149,"uuid":"204850074","full_name":"mechero/spring-boot-rest-exceptions","owner":"mechero","description":"Custom error formatting and exception handling in Rest Controllers with Spring Boot","archived":false,"fork":false,"pushed_at":"2019-09-11T05:29:00.000Z","size":337,"stargazers_count":97,"open_issues_count":0,"forks_count":29,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T21:31:02.535Z","etag":null,"topics":["controller-advice","error-handling","exception-handler","java","java12","rest-api","spring-boot"],"latest_commit_sha":null,"homepage":"https://thepracticaldeveloper.com/2019/09/09/custom-error-handling-rest-controllers-spring-boot/","language":"Java","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/mechero.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-08-28T04:47:07.000Z","updated_at":"2024-11-11T22:19:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"e85dfcd5-d8a9-4d25-b2c3-82eca3fc5b77","html_url":"https://github.com/mechero/spring-boot-rest-exceptions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechero%2Fspring-boot-rest-exceptions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechero%2Fspring-boot-rest-exceptions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechero%2Fspring-boot-rest-exceptions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechero%2Fspring-boot-rest-exceptions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mechero","download_url":"https://codeload.github.com/mechero/spring-boot-rest-exceptions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251652172,"owners_count":21621897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["controller-advice","error-handling","exception-handler","java","java12","rest-api","spring-boot"],"created_at":"2024-10-03T11:18:40.777Z","updated_at":"2025-04-30T06:22:56.092Z","avatar_url":"https://github.com/mechero.png","language":"Java","readme":"# Handling errors in REST Controllers with Spring Boot\n\n## Goal \n\nThis sample code shows how configure a Spring Boot application to properly handle all exceptions and create your custom error format.\n\nCheck the [blog post](https://thepracticaldeveloper.com/2019/09/09/custom-error-handling-rest-controllers-spring-boot/) on ThePracticalDeveloper site for the complete guide with instructions.\n\n![Custom Error Handling in Spring Boot REST Controllers](img/custom-error-handling.png)\n\nAnd, if you find this code useful, please give a star to the repo!\n\n## Custom error handling\n\nFirst, you'll find in this code an example of a basic approach to map exceptions to status codes in Spring Boot using a `@RestControllerAdvice` with `@ExceptionHandler` methods.\n\nHowever, the most interesting part is the injection of a customized `ErrorController` implementation and the overridden `ErrorAttributes` to achieve consistent responses when dealing with errors.\n\nFor this example, I used the Google JSON Style Guide but you can use any other known error formatting or create your own one.\n\nCheck [the guide](https://thepracticaldeveloper.com/2019/09/09/custom-error-handling-rest-controllers-spring-boot/) for more details. \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmechero%2Fspring-boot-rest-exceptions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmechero%2Fspring-boot-rest-exceptions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmechero%2Fspring-boot-rest-exceptions/lists"}