From a9039e0c26ae26e3f2e0863b730b4fbdc298eb21 Mon Sep 17 00:00:00 2001 From: huanghai <10402852@qq.com> Date: Sat, 18 Jul 2020 11:03:22 +0800 Subject: [PATCH] 'commit' --- dsBaseRpc/Test/ErrorTest/ErrorTest.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dsBaseRpc/Test/ErrorTest/ErrorTest.go b/dsBaseRpc/Test/ErrorTest/ErrorTest.go index b91d8529..3fc6fc62 100644 --- a/dsBaseRpc/Test/ErrorTest/ErrorTest.go +++ b/dsBaseRpc/Test/ErrorTest/ErrorTest.go @@ -5,7 +5,11 @@ import ( "log" "net/http" ) - +/** +从golang的异常机制可以看出,异常处理recover最好是在接口的入口处 +就将其插入到对应defer队列中。这样在接口调用过程中,即使发生异常, +程序依然可以提供服务。 + */ func HelloServer(w http.ResponseWriter, req *http.Request) { //在可能出现异常的函数调用前,使用defer进行加入defer队列,即使出现异常,也不会整个进程退出~ defer func() {