Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alba María Álvarez
/
AppRecetas
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
66cdd85e
authored
Aug 17, 2025
by
Alba María Álvarez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat(exception): añadido handler para PythonApiException y control para IllegalArgumentException
parent
5f7d301c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
src/main/java/com/example/apprecetas/exception/ExceptionController.java
src/main/java/com/example/apprecetas/exception/ExceptionController.java
View file @
66cdd85e
...
...
@@ -12,9 +12,9 @@ import java.time.LocalDateTime;
@RestControllerAdvice
public
class
ExceptionController
{
@ExceptionHandler
(
UnprocessableEntityException
.
class
)
@ExceptionHandler
(
{
UnprocessableEntityException
.
class
,
IllegalArgumentException
.
class
}
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
public
ResponseEntity
<
ErrorMessage
>
handle
(
UnprocessableEntity
Exception
ex
)
{
public
ResponseEntity
<
ErrorMessage
>
handle
(
Runtime
Exception
ex
)
{
return
new
ResponseEntity
<>(
new
ErrorMessage
(
LocalDateTime
.
now
(),
HttpStatus
.
BAD_REQUEST
.
value
(),
ex
.
getMessage
()),
HttpStatusCode
.
valueOf
(
HttpStatus
.
BAD_REQUEST
.
value
()));
}
...
...
@@ -26,4 +26,15 @@ public class ExceptionController {
ex
.
getMessage
()),
HttpStatusCode
.
valueOf
(
HttpStatus
.
NOT_FOUND
.
value
()));
}
@ExceptionHandler
(
PythonApiException
.
class
)
public
ResponseEntity
<
ErrorMessage
>
handle
(
PythonApiException
ex
)
{
return
ResponseEntity
.
status
(
ex
.
getStatus
()).
body
(
new
ErrorMessage
(
LocalDateTime
.
now
(),
ex
.
getStatus
().
value
(),
ex
.
getMessage
()
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment