Quick fix to handle bad requests
This commit is contained in:
parent
3ab0e395b3
commit
3a67e48ab0
17
api/src/features/ErrorFeature.kt
Normal file
17
api/src/features/ErrorFeature.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package be.vandewalleh.features
|
||||
|
||||
import io.ktor.application.Application
|
||||
import io.ktor.application.call
|
||||
import io.ktor.application.install
|
||||
import io.ktor.features.StatusPages
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.response.respond
|
||||
import io.ktor.utils.io.errors.IOException
|
||||
|
||||
fun Application.handleErrors() {
|
||||
install(StatusPages) {
|
||||
exception<IOException> { _ ->
|
||||
call.respond(HttpStatusCode.BadRequest)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,4 +7,5 @@ fun Application.features() {
|
||||
corsFeature()
|
||||
contentNegotiationFeature()
|
||||
authenticationModule()
|
||||
handleErrors()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user