From 7c41b42fb120a6a0f7e7bf57c88a3d42856b7420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BD=A6=E5=8E=98=E5=AD=90?= Date: Fri, 9 Dec 2022 17:54:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=F0=9F=9B=A0=EF=B8=8F:=20=E4=BF=AE=E6=94=B9b?= =?UTF-8?q?ill=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/cn/fadinglight/routes/BillRoutes.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/cn/fadinglight/routes/BillRoutes.kt b/src/main/kotlin/cn/fadinglight/routes/BillRoutes.kt index f20b1e0..01679f4 100644 --- a/src/main/kotlin/cn/fadinglight/routes/BillRoutes.kt +++ b/src/main/kotlin/cn/fadinglight/routes/BillRoutes.kt @@ -40,7 +40,6 @@ fun Route.billRoute() { }.onSuccess { call.respond(Resp.Ok(it).json()) }.onFailure { - it.printStackTrace() call.respond(Resp.Error(it.message, code = -1).json()) } } @@ -57,9 +56,14 @@ fun Route.billRoute() { } put("/") { - val bill = call.receive().bill() - val count = billService.updateOneBill(bill) - call.respond(status = HttpStatusCode.OK, Resp.Ok(count).json()) + runCatching { + val bill = call.receive().bill() + billService.updateOneBill(bill) + }.onSuccess { + call.respond(status = HttpStatusCode.OK, Resp.Ok(it).json()) + }.onFailure { + call.respond(Resp.Error(it.message).json()) + } } } } \ No newline at end of file