Exceptions - THM-ATLAS/spring-backend GitHub Wiki
The ApiError class provides the basic framework for an error
-
timestampTime at which Error occurred -
codeError code -
statusError status -
errorsError that is thrown -
messageDescription why error occurred
List of all exceptions with short description sorted by status codes
EmptyParameterException One/multiple requested/posted parameters are empty
InvalidParameterTypeException One/multiple requested/posted parameters are invalid types
InvalidParameterLengthException One/multiple requested/posted parameters are too long/short
Invalid<Class>IDException Invalid ID when creating (Must be zero)
IconInUseException Icon still in use, cannot be deleted
InvalidCredentialsException Invalid Credentials when trying to log in
AccessDeniedException User not allowed to view this page
NoPermissionToDelete<Class>Exception User is not allowed to delete this
NoPermissionToEdit<Class>Exception User is not allowed to edit this
NoPermissionToModify<Class>Exception User is not allowed to create/edit/delete >Class>
NoPermissionToAddUserToModuleException User is not allowed to add this user to module
NoPermissionToRemoveUserFromModuleException User is not allowed to remove this user from module
UserCannotBeAddedToModuleException User is not allowed to be added to modules
UserNotInModuleException User can't be found in module
SubmissionAfterDeadlineException Submission was too late
NoAccessToExerciseException User doesn't have access to exercise
UserNeedsToSubmitBeforeRatingException User didn't enter submission for this exercise, can't rate exercise
NoPermissionToPostNotificationException User has no Permission to send this notification
NoPermissionToRemoveNotificationRelationException User has no Permission remove this Notification for this user
NoPermissionToCreateIconException Only Admins can create new Icons
NoPermissionToMarkAsReadException Users may only mark their own notifications as read
PageNotFoundException Accessed Page doesn't exist
<Class>NotFoundException ID doesn't exist
UnprocessableEntityException Entity couldn't be processed
UserAlreadyExistsException Username already exists in the database
SubmissionAlreadyExistsException User already submitted to that task
WrongSubmissionTypeException Exercise Type and submission types have to match. The submission type given inside the submission and the actually given type have to match
QuestionDoesNotBelongToExerciseException Question given to a wrong task
AnswerDoesNotBelongToQuestionException Answer was given to a false question
ExerciseMustIncludeMcSchemeException Exercises with mc type must include a mc scheme
ReservedLdapUsernameException The submitted username is reserved for LDAP users
BadPasswordException The submitted password does not meet the required criteria
InternalServerError Unexpected Server Error
NotYetImplementedException Method not implemented yet
src/main/kotlin/com/example/atlasbackend/exception/Exceptions.kt
The GlobalExceptionHandler implements the error objects from Exceptions.kt using the ApiError class
@ExceptionHandler(value = [<ExceptionObject>::class])
fun exception(exception: <ExceptionObject>): ResponseEntity<ApiError> {
val err = ApiError(<statuscode>, HttpStatus.<status>, "<ExceptionObject>", "<message>")
return ResponseEntity<ApiError>(err, HttpStatus.<statuscode>)
}