You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2021/05/31 02:07:15 UTC
[apisix-go-plugin-runner] 08/22: chore: tweak error handling
This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-go-plugin-runner.git
commit f00ec5ec4bb4ea2e418ebb70c61826a356484ed1
Author: spacewander <sp...@gmail.com>
AuthorDate: Wed May 19 17:46:31 2021 +0800
chore: tweak error handling
---
internal/server/server.go | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/internal/server/server.go b/internal/server/server.go
index 26ab5cf..c2deef9 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -17,6 +17,7 @@ package server
import (
"encoding/binary"
"errors"
+ "fmt"
"io"
"net"
"os"
@@ -95,6 +96,14 @@ func handleConn(c net.Conn) {
switch ty {
case RPCPrepareConf:
out, err = plugin.PrepareConf(buf)
+ default:
+ err = fmt.Errorf("unknown type %d", ty)
+ }
+
+ size := len(out)
+ if size > MaxDataSize {
+ err = fmt.Errorf("the max length of data is %d but got %d", MaxDataSize, size)
+ log.Errorf("%s", err)
}
if err != nil {
@@ -102,12 +111,6 @@ func handleConn(c net.Conn) {
out = ReportError(err)
}
- size := len(out)
- if size > MaxDataSize {
- log.Errorf("the max length of data is %d but got %d", MaxDataSize, size)
- continue
- }
-
binary.BigEndian.PutUint32(header, uint32(size))
header[0] = ty