Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TAM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EIP
Labrador
TAM
Merge requests
!357
Draft: Add HeadTA Job Offers + Constraint Violation Errors
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Draft: Add HeadTA Job Offers + Constraint Violation Errors
192-indicate-job-offer-sets-head-ta-role-instead-of-ta
into
dev
Overview
8
Commits
9
Pipelines
19
Changes
22
Closed
Timur Oberhuber
requested to merge
192-indicate-job-offer-sets-head-ta-role-instead-of-ta
into
dev
1 year ago
Overview
8
Commits
9
Pipelines
19
Changes
22
Expand
Description
Add HeadTA Job Offers
Add Constraint Violation Error Messages
Related Issues
Resolve
#192
Resolve
#196
Checklist
I have added a changelog entry to reflect the significant changes I made.
Edited
1 year ago
by
Timur Oberhuber
1
0
Merge request reports
Compare
dev
version 8
c922b6bd
10 months ago
version 7
f287a173
10 months ago
version 6
e3e78450
11 months ago
version 5
8afaa54b
11 months ago
version 4
d66a5c20
1 year ago
version 3
d84abef7
1 year ago
version 2
f64c6d83
1 year ago
version 1
32a7cb45
1 year ago
dev (base)
and
latest version
latest version
a1e85936
9 commits,
8 months ago
version 8
c922b6bd
8 commits,
10 months ago
version 7
f287a173
7 commits,
10 months ago
version 6
e3e78450
6 commits,
11 months ago
version 5
8afaa54b
5 commits,
11 months ago
version 4
d66a5c20
4 commits,
1 year ago
version 3
d84abef7
3 commits,
1 year ago
version 2
f64c6d83
2 commits,
1 year ago
version 1
32a7cb45
1 commit,
1 year ago
22 files
+
313
−
12
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
22
Search (e.g. *.vue) (Ctrl+P)
src/main/java/nl/tudelft/tam/controller/advice/GlobalExceptionHandler.java
0 → 100644
+
68
−
0
Options
/*
* TAM
* Copyright (C) 2021 - Delft University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
nl.tudelft.tam.controller.advice
;
import
java.util.stream.Collectors
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
nl.tudelft.tam.exception.ConstraintViolationDetailedException
;
@ControllerAdvice
public
class
GlobalExceptionHandler
{
@ExceptionHandler
(
ConstraintViolationDetailedException
.
class
)
public
String
handleConstraintViolationException
(
Model
model
,
ConstraintViolationDetailedException
ex
)
{
StackTraceElement
topOfStack
=
ex
.
getStackTrace
()[
0
];
String
className
=
topOfStack
.
getClassName
();
String
methodName
=
topOfStack
.
getMethodName
();
String
errorMessage
=
ex
.
getConstraintViolations
().
stream
()
.
map
(
violation
->
violation
.
getPropertyPath
()
+
" "
+
violation
.
getMessage
())
.
collect
(
Collectors
.
joining
(
", "
));
switch
(
className
)
{
case
"nl.tudelft.tam.controller.JobOfferController"
:
switch
(
methodName
)
{
case
"createJobOffer"
:
model
.
addAttribute
(
"jobOfferCreationError"
,
errorMessage
);
return
"job_offer/manage"
;
case
"patchJobOffer"
:
model
.
addAttribute
(
"editingError"
,
errorMessage
);
return
"redirect:/job-offer/"
+
ex
.
getRedirectId
();
case
"patchJobOfferMessages"
:
model
.
addAttribute
(
"messageEditingError"
,
errorMessage
);
return
"redirect:/job-offer/"
+
ex
.
getRedirectId
();
}
case
"nl.tudelft.tam.controller.ExtraWorkController"
:
switch
(
methodName
)
{
case
"createExtraWork"
:
model
.
addAttribute
(
"extraWorkCreationError"
,
errorMessage
);
return
"job_offer/manage"
;
case
"patchExtraWork"
:
model
.
addAttribute
(
"editingError"
,
errorMessage
);
return
"redirect:/extra-work/"
+
ex
.
getRedirectId
();
}
}
throw
ex
;
}
}
Loading