Skip to content

fix: add centralized @ControllerAdvice exception handler#1147

Open
PranavAgarkar07 wants to merge 1 commit into
viru0909-dev:mainfrom
PranavAgarkar07:fix/1041-global-exception-handler
Open

fix: add centralized @ControllerAdvice exception handler#1147
PranavAgarkar07 wants to merge 1 commit into
viru0909-dev:mainfrom
PranavAgarkar07:fix/1041-global-exception-handler

Conversation

@PranavAgarkar07

@PranavAgarkar07 PranavAgarkar07 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

Uncaught backend exceptions were leaking raw stack traces and internal details to API users, posing a security risk.

Changes

  • Created GlobalExceptionHandler with @RestControllerAdvice
  • Added structured JSON error responses (error, message, status, timestamp)
  • Covers: validation errors (400), not found (404), access denied (403), bad request (400), generic errors (500)
  • Created NotFoundException and ResourceNotFoundException custom exceptions

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Related Issue

Closes #1041

@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

@PranavAgarkar07 is attempting to deploy a commit to the CodeBlooded's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Hi @PranavAgarkar07, thanks for contributing to Nyay Setu! 🎉

I have automatically:

  • 👤 Assigned this PR to you.
  • 🏷️ Applied the gssoc:approved label.

Our workflows will now analyze your changes to classify:

  • 📈 PR Difficulty: level:*
  • 🧩 PR Type: type:*
  • 🌟 PR Quality: quality:*

Tip

Ensure your PR description references the issue it resolves (e.g. Closes #123). This allows the bot to inherit any additional labels from that issue!

Happy coding! 🚀

@PranavAgarkar07

Copy link
Copy Markdown
Contributor Author

@viru0909-dev This PR is ready for review — CI passes, all labels applied (including gssoc:approved). Could you take a look and merge when convenient? Thanks!

@viru0909-dev viru0909-dev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires Changes. Please address the following issues:

Backend tests failed:\n\n[ERROR] COMPILATION ERROR : [ERROR] /private/tmp/nyay-setu-working-fix/backend/nyaysetu-backend/src/main/java/com/nyaysetu/backend/exception/GlobalExceptionHandler.java:[45,95] cannot find symbol [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project nyaysetu-backend: Compilation failure [ERROR] /private/tmp/nyay-setu-working-fix/backend/nyaysetu-backend/src/main/java/com/nyaysetu/backend/exception/GlobalExceptionHandler.java:[45,95] cannot find symbol [ERROR] symbol: class AuthorizationDeniedException [ERROR] location: package org.springframework.security.authorization [ERROR] [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.\n

@viru0909-dev viru0909-dev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR has been reviewed and requires changes before it can be approved. The issues below must be resolved.

Issues to Resolve

Result Check Notes
FAIL Description Description is missing: a Type of Change section; a Checklist section with checkboxes.
FAIL Checklist No checklist found in the description.

Passing Checks

Result Check Notes
PASS Title Title format is acceptable.
PASS Issue Link Issue is linked with a closing keyword.
PASS Merge Conflicts Conflict status is not yet computed by GitHub — skipping.
PASS Branch Freshness Branch was last updated 2.5 days ago.
PASS CI / Tests No CI checks are configured or results are not yet available.
PASS Code Quality No code quality issues detected in the diff.

To proceed: push the required fixes to fix/1041-global-exception-handler and the PR will be re-evaluated on the next review run.

…rs, add EntityNotFoundException/ResourceNotFoundException
@PranavAgarkar07 PranavAgarkar07 force-pushed the fix/1041-global-exception-handler branch from 9092dc4 to 201fdd7 Compare June 16, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: feat: implement centralized Spring Boot @ControllerAdvice Exception Handler

2 participants