From 99e7d0f59bf5790f76ed7057eab5b844d0990a6b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 12 Aug 2021 15:55:53 +0800 Subject: [PATCH] 1 --- httpserver.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/httpserver.go b/httpserver.go index c825684..a5e3b7d 100644 --- a/httpserver.go +++ b/httpserver.go @@ -85,6 +85,10 @@ func (this *HttpServer) dispatchRequest(c *Context) { atomic.CompareAndSwapInt64(&this.maxHandleTime, oldVal, endTick - beginTick) } atomic.AddInt64(&this.okTimes, 1) + if err := recover(); err != nil { + SysLog().Error("handle name:%s error:%s", handleName, err) + c.Response(`{"errcode":500, "errmsg":"服务器内部错误"}`) + } }() handle(c) } else {