From 39c9d8169f3b013580c0cf190b909d7723e8e423 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 24 Apr 2018 23:42:21 +0200 Subject: [PATCH] [server] explicit errors --- src/git.xdrm.io/schastsp/server/server.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/git.xdrm.io/schastsp/server/server.go b/src/git.xdrm.io/schastsp/server/server.go index d0aa236..7b68c3e 100644 --- a/src/git.xdrm.io/schastsp/server/server.go +++ b/src/git.xdrm.io/schastsp/server/server.go @@ -84,14 +84,14 @@ func (s *T) HandleRequest(req io.Reader, res io.Writer) error { /* (1) Read x1 */ x1 := make([]byte, scha.HSIZE); read, err := req.Read(x1); - if err != nil { return err } - if uint16(read) != scha.HSIZE { return errors.New("Cannot read enough bytes") } + if err != nil { return fmt.Errorf("Reading x1 : %s", err) } + if uint16(read) != scha.HSIZE { return fmt.Errorf("Cannot read x1 : %d / %d bytes available", read, scha.HSIZE) } /* (2) Read x2 */ x2 := make([]byte, scha.HSIZE); read, err = req.Read(x2); - if err != nil { return err } - if uint16(read) != scha.HSIZE { return errors.New("Cannot read enough bytes") } + if err != nil { return fmt.Errorf("Reading x2 : %s", err) } + if uint16(read) != scha.HSIZE { return fmt.Errorf("Cannot read x2 : %d / %d bytes available", read, scha.HSIZE) } /* (3) Manage request */ errCode, err := s.manageRequest(x1, x2)