From 66d5b195c5f2665d0249316f72ba7e1e49a5b508 Mon Sep 17 00:00:00 2001 From: Amir Hossein <77993374+Kamandlou@users.noreply.github.com> Date: Wed, 28 Sep 2022 15:56:20 +0330 Subject: [PATCH] fix unhandled errors and update code comments to help the IDEs (#2128) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix unhandled errors * fix unhandled error in cache package test * omit variable type * omit variable type * rename variable because collide with the imported package name * handle file error on closing * fix unhandled in common_linux.go * fix unhandled errors in helpers_test.go * fix unhandled errors in listen_test.go * remove unused parameter in emptyHandler method * refactor path.go * unhandled error in hooks test * fix unhandled errors in app_test.go * fix unhandled errors in ctx_test.go * ✨ fix unhandled errors in helpers_test.go * revert app_test.go * remove redundant parentheses and update comments * update code comment for helping ide * update code comment for helping ide * fix unhandled error in app_test.go * update code comments for helping IDEs * fix unhandled errors in app_test.go * update code comment for helping the IDEs --- app_test.go | 10 ++++++++-- error.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app_test.go b/app_test.go index ec9224dbc2..7aff77476c 100644 --- a/app_test.go +++ b/app_test.go @@ -1343,7 +1343,10 @@ func Test_App_ReadTimeout(t *testing.T) { conn, err := net.Dial(NetworkTCP4, "127.0.0.1:4004") utils.AssertEqual(t, nil, err) - defer conn.Close() + defer func(conn net.Conn) { + err := conn.Close() + utils.AssertEqual(t, nil, err) + }(conn) _, err = conn.Write([]byte("HEAD /read-timeout HTTP/1.1\r\n")) utils.AssertEqual(t, nil, err) @@ -1375,7 +1378,10 @@ func Test_App_BadRequest(t *testing.T) { time.Sleep(500 * time.Millisecond) conn, err := net.Dial(NetworkTCP4, "127.0.0.1:4005") utils.AssertEqual(t, nil, err) - defer conn.Close() + defer func(conn net.Conn) { + err := conn.Close() + utils.AssertEqual(t, nil, err) + }(conn) _, err = conn.Write([]byte("BadRequest\r\n")) utils.AssertEqual(t, nil, err) diff --git a/error.go b/error.go index 9d0d0de250..e520420a78 100644 --- a/error.go +++ b/error.go @@ -7,7 +7,7 @@ import ( ) type ( - // Conversion error exposes the internal schema.ConversionError for public use. + // ConversionError Conversion error exposes the internal schema.ConversionError for public use. ConversionError = schema.ConversionError // UnknownKeyError error exposes the internal schema.UnknownKeyError for public use. UnknownKeyError = schema.UnknownKeyError