add errormsg 35/204535/1
authorjaehoon.hyun <jaehoon.hyun@samsung.com>
Wed, 24 Apr 2019 07:09:25 +0000 (16:09 +0900)
committerjaehoon.hyun <jaehoon.hyun@samsung.com>
Wed, 24 Apr 2019 07:09:32 +0000 (16:09 +0900)
Change-Id: I1f86553b843472fa19a9e4d1b83105ef4df5a728
Signed-off-by: jaehoon.hyun <jaehoon.hyun@samsung.com>
src/errormsg/errormsg.go [new file with mode: 0644]
src/errormsg/errormsg_test.go [new file with mode: 0644]

diff --git a/src/errormsg/errormsg.go b/src/errormsg/errormsg.go
new file mode 100644 (file)
index 0000000..832c898
--- /dev/null
@@ -0,0 +1,45 @@
+package errormsg\r
+\r
+import (\r
+       "errors"\r
+       "strconv"\r
+)\r
+\r
+type OrchestrationError int\r
+\r
+const (\r
+       ErrorNotReadyOrchestrationInit = ((1 + iota) ^ -1) + 1\r
+       ErrorTurnOffWifi\r
+       ErrorDisconnectWifi\r
+)\r
+\r
+var orchestrationErrorString = [...]string{\r
+       "",\r
+       "ErrorNotReadyOrchestrationInit : \" Please wait until Orchestration init function has been completed \" ",\r
+       "ErrorTurnOffWifi : \" Please Turn On Wifi \" ",\r
+       "ErrorDisconnectWifi : \" Please Connect Wifi \" ",\r
+}\r
+\r
+func ToString(args interface{}) string {\r
+\r
+       switch args.(type) {\r
+       case int:\r
+               v := args.(int)\r
+               return orchestrationErrorString[v*-1]\r
+       case error:\r
+               err := args.(error)\r
+               v, _ := strconv.Atoi(err.Error())\r
+               return orchestrationErrorString[v*-1]\r
+       }\r
+\r
+       return "NOT SUPPORT TYPE"\r
+}\r
+\r
+func ToError(orcheError int) error {\r
+       return errors.New(strconv.Itoa(orcheError))\r
+}\r
+\r
+func ToInt(err error) int {\r
+       v, _ := strconv.Atoi(err.Error())\r
+       return v\r
+}\r
diff --git a/src/errormsg/errormsg_test.go b/src/errormsg/errormsg_test.go
new file mode 100644 (file)
index 0000000..e35ff55
--- /dev/null
@@ -0,0 +1,11 @@
+package errormsg\r
+\r
+import \r
+(\r
+       "testing"\r
+)\r
+\r
+func TestErrorMsg(t *testing.T) {\r
+       err := ToError(ErrorNotReadyOrchestrationInit)\r
+       t.Log(ToString(err))\r
+}
\ No newline at end of file