diff --git a/internal/codec.go b/internal/codec.go
index bb671ca..9c6be76 100644
--- a/internal/codec.go
+++ b/internal/codec.go
@@ -127,7 +127,10 @@ func GetMsgs(soap string) []string {
func GetErrMsg(soap string) string {
r, _ := regexp.Compile(errExp)
msg := r.FindAllString(soap, -1)
- if len(msg) > 0 && len(msg[0]) > 40 {
+ if len(msg) < 1 {
+ return ""
+ }
+ if len(msg[0]) > 40 {
size := len(msg[0])
return msg[0][54 : size-15]
}
diff --git a/internal/codec_test.go b/internal/codec_test.go
index f5382e7..f643648 100644
--- a/internal/codec_test.go
+++ b/internal/codec_test.go
@@ -94,6 +94,8 @@ const (
Msg string = ` AODB 820830 20180527124442 FLOP ESTT 10725849 CA-CA4242-A-27MAY181955-D 27MAY181945 `
ErrMsg string = `soap:Serverinvalid route envent id 20Can not find the event [FLOP-ESTT-ATC-ALL1]`
+
+ SendOk string = ``
)
func TestSend(t *testing.T) {
@@ -126,3 +128,9 @@ func TestGetErrMsg(t *testing.T) {
errMsg := GetErrMsg(ErrMsg)
assert.Equal("Can not find the event [FLOP-ESTT-ATC-ALL1]", errMsg)
}
+
+func TestSendOk(t *testing.T) {
+ assert := assert.New(t)
+ errMsg := GetErrMsg(SendOk)
+ assert.Equal("", errMsg)
+}