Adds login ability, error handling, and logging (#1)

Reviewed-on: #1
Co-authored-by: aarbit <aarbit@gmail.com>
Co-committed-by: aarbit <aarbit@gmail.com>
This commit was merged in pull request #1.
This commit is contained in:
2025-12-19 05:15:18 +00:00
committed by aarbit
parent 302feeab1e
commit 04b61485ea
13 changed files with 155 additions and 8 deletions

View File

@@ -0,0 +1,31 @@
package net.halfbinary.scavengerhuntapi.error
import net.halfbinary.scavengerhuntapi.error.exception.InvalidEmailException
import net.halfbinary.scavengerhuntapi.error.exception.LoginFailedException
import net.halfbinary.scavengerhuntapi.error.exception.PreexistingAccountException
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
@RestControllerAdvice
class ExceptionHandler {
@ExceptionHandler(PreexistingAccountException::class)
@ResponseStatus(HttpStatus.CONFLICT)
fun preexistingAccountException(e: PreexistingAccountException): String? {
return e.message
}
@ExceptionHandler(LoginFailedException::class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
fun loginFailedException(e: LoginFailedException): String? {
return e.message
}
@ExceptionHandler(InvalidEmailException::class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
fun invalidEmailException(e: InvalidEmailException): String? {
return e.message
}
}