Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend] Avoid raising stack trace instead of returning a 404 #885

Merged
merged 1 commit into from
May 22, 2024

Conversation

Dimfacion
Copy link
Member

@Dimfacion Dimfacion commented May 15, 2024

Proposed changes

  • Instead of raising IllegalStateException or the generic NoSuchElementException, we're raising a custom defined Exception to keep the hand on where it is raised
  • Adding a global exception handler to take care of the new exception and return a proper 404. The handler could be extended to add more intel when an exception is raised.

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 7.18232% with 168 lines in your changes are missing coverage. Please review.

Project coverage is 27.31%. Comparing base (cedad5f) to head (e5976fc).
Report is 3 commits behind head on master.

Files Patch % Lines
...ain/java/io/openbas/rest/exercise/ExerciseApi.java 0.00% 34 Missing ⚠️
...rc/main/java/io/openbas/rest/inject/InjectApi.java 17.39% 19 Missing ⚠️
.../main/java/io/openbas/rest/channel/ChannelApi.java 25.00% 12 Missing ⚠️
...ain/java/io/openbas/rest/document/DocumentApi.java 0.00% 12 Missing ⚠️
.../main/java/io/openbas/rest/lessons/LessonsApi.java 0.00% 9 Missing ⚠️
.../src/main/java/io/openbas/rest/group/GroupApi.java 0.00% 8 Missing ⚠️
...n/java/io/openbas/rest/objective/ObjectiveApi.java 0.00% 8 Missing ⚠️
...pi/src/main/java/io/openbas/rest/team/TeamApi.java 0.00% 6 Missing ⚠️
...-api/src/main/java/io/openbas/rest/user/MeApi.java 0.00% 6 Missing ⚠️
...nbas/rest/lessons_template/LessonsTemplateApi.java 0.00% 5 Missing ⚠️
... and 22 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #885      +/-   ##
============================================
- Coverage     27.31%   27.31%   -0.01%     
- Complexity      917      919       +2     
============================================
  Files           410      412       +2     
  Lines          9280     9288       +8     
  Branches        431      431              
============================================
+ Hits           2535     2537       +2     
- Misses         6685     6691       +6     
  Partials         60       60              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RomuDeuxfois
Copy link
Member

We need to rethink the management of 404 on the front side.
image

The user has an infinite loader when the entity does not exist right now, we need to display a 404 error message.
image

@RomuDeuxfois RomuDeuxfois merged commit dfb6fa0 into master May 22, 2024
6 checks passed
@RomuDeuxfois RomuDeuxfois deleted the issue/867 branch May 22, 2024 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid raising stack trace when entity is not found, just returning 404
2 participants