File tree 1 file changed +12
-2
lines changed
app/src/main/java/me/capcom/smsgateway/modules/localserver
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import io.ktor.server.auth.authenticate
21
21
import io.ktor.server.auth.basic
22
22
import io.ktor.server.engine.embeddedServer
23
23
import io.ktor.server.netty.Netty
24
+ import io.ktor.server.plugins.BadRequestException
25
+ import io.ktor.server.plugins.NotFoundException
24
26
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
25
27
import io.ktor.server.plugins.statuspages.StatusPages
26
28
import io.ktor.server.response.header
@@ -96,9 +98,11 @@ class WebService : Service() {
96
98
call.respond(
97
99
when (cause) {
98
100
is IllegalArgumentException -> HttpStatusCode .BadRequest
101
+ is BadRequestException -> HttpStatusCode .BadRequest
102
+ is NotFoundException -> HttpStatusCode .NotFound
99
103
else -> HttpStatusCode .InternalServerError
100
104
},
101
- mapOf (" message" to cause.message )
105
+ mapOf (" message" to cause.description )
102
106
)
103
107
}
104
108
}
@@ -236,4 +240,10 @@ class WebService : Service() {
236
240
context.stopService(Intent (context, WebService ::class .java))
237
241
}
238
242
}
239
- }
243
+ }
244
+
245
+ private val Throwable .description: String
246
+ get() {
247
+ return (localizedMessage ? : message ? : toString()) +
248
+ (cause?.let { " : " + it.description } ? : " " )
249
+ }
You can’t perform that action at this time.
0 commit comments