Skip to content

Commit

Permalink
feat: DuplicateSurveyException 핸들러를 추가한다
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb committed Mar 6, 2024
1 parent 5fc2e04 commit 3200ead
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package me.nalab.survey.web.adaptor.advice;

import me.nalab.survey.application.exception.DuplicateSurveyException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import me.nalab.survey.application.exception.SurveyDoesNotExistException;
import me.nalab.survey.application.exception.SurveyDoesNotHasTargetException;
import me.nalab.survey.application.exception.TargetDoesNotExistException;
import me.nalab.survey.application.exception.TargetDoesNotHasSurveyException;

Expand All @@ -32,4 +32,10 @@ ErrorTemplate handleSurveyDoesNotExistException(SurveyDoesNotExistException surv
"Cannot found any survey form id \"" + surveyDoesNotExistException.getSurveyId() + "\"");
}

@ExceptionHandler(DuplicateSurveyException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ErrorTemplate handleDuplicateSurveyException(DuplicateSurveyException duplicateSurveyException) {
return ErrorTemplate.of(duplicateSurveyException.getMessage());
}

}

0 comments on commit 3200ead

Please sign in to comment.