Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
Paul-Christian Volkmer
ARSnova Backend
Commits
1fd47588
Commit
1fd47588
authored
9 years ago
by
Klaus-Dieter Quibeldey-Cirkel
Browse files
Options
Downloads
Plain Diff
Merge pull request
#27
from pcvolkmer/defaultExceptionHandler
Add a default exception handler to catch non handled exceptions
parents
b8bee647
56fe085e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/thm/arsnova/controller/SecurityExceptionControllerAdvice.java
+17
-1
17 additions, 1 deletion
...arsnova/controller/SecurityExceptionControllerAdvice.java
with
17 additions
and
1 deletion
src/main/java/de/thm/arsnova/controller/SecurityExceptionControllerAdvice.java
+
17
−
1
View file @
1fd47588
...
...
@@ -17,6 +17,9 @@
*/
package
de.thm.arsnova.controller
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -35,9 +38,9 @@ import de.thm.arsnova.exceptions.ForbiddenException;
import
de.thm.arsnova.exceptions.NoContentException
;
import
de.thm.arsnova.exceptions.NotFoundException
;
import
de.thm.arsnova.exceptions.NotImplementedException
;
import
de.thm.arsnova.exceptions.PayloadTooLargeException
;
import
de.thm.arsnova.exceptions.PreconditionFailedException
;
import
de.thm.arsnova.exceptions.UnauthorizedException
;
import
de.thm.arsnova.exceptions.PayloadTooLargeException
;
/**
* Translates security/authentication related exceptions into HTTP status codes.
...
...
@@ -45,6 +48,19 @@ import de.thm.arsnova.exceptions.PayloadTooLargeException;
@ControllerAdvice
public
class
SecurityExceptionControllerAdvice
{
@ExceptionHandler
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
Map
<
String
,
String
>
defaultExceptionHandler
(
final
Exception
e
,
final
HttpServletRequest
req
)
{
final
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>();
result
.
put
(
"code"
,
"500"
);
result
.
put
(
"status"
,
"Internal server error"
);
result
.
put
(
"message"
,
e
.
getMessage
());
return
result
;
}
@ResponseStatus
(
HttpStatus
.
NOT_FOUND
)
@ExceptionHandler
(
NotFoundException
.
class
)
public
void
handleNotFoundException
(
final
Exception
e
,
final
HttpServletRequest
request
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment