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 {