From 2baee4a0664a8a08d54b985663f2cf197c882c93 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 27 Sep 2018 14:33:03 +0200 Subject: [PATCH] update 'driver/generic' now working (~44ms for simplest use) --- driver/generic.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/driver/generic.go b/driver/generic.go index 6c831f6..bbe668a 100644 --- a/driver/generic.go +++ b/driver/generic.go @@ -45,16 +45,26 @@ func (d *Generic) Load(_path []string, _method string) (func(response.Arguments) } /* (3) Get output json */ - output := make(response.Arguments) - err2 = json.Unmarshal(stdout, output) + var outputI interface{} + err2 = json.Unmarshal(stdout, &outputI) + if err2 != nil { + res.Err = err.UncallableController + return *res + } + + output, ok := outputI.(map[string]interface{}) + if !ok { + res.Err = err.UncallableController + return *res + } res.Err = err.Success // extract error (success by default or on error) if outErr, ok := output["error"]; ok { - tmpErr, ok := outErr.(err.Error) + errCode, ok := outErr.(float64) if ok { - res.Err = tmpErr + res.Err = err.Error{int(errCode), "unknown reason", nil} } delete(output, "error")