summaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorlost+skunk <[email protected]>2024-09-04 20:18:39 +0300
committerlost+skunk <[email protected]>2024-09-04 20:18:39 +0300
commitb3c99749f133abf6c04506135c2e4e7567da5254 (patch)
tree2dd1abd4967eae3d151eff30404ab28ffd7054b1 /util.go
parent4487cdcbe9ed2ad4bc661c04600336505054177c (diff)
downloaddevianter-b3c99749f133abf6c04506135c2e4e7567da5254.tar.gz
devianter-b3c99749f133abf6c04506135c2e4e7567da5254.tar.bz2
devianter-b3c99749f133abf6c04506135c2e4e7567da5254.zip
ошибки
Diffstat (limited to 'util.go')
-rw-r--r--util.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/util.go b/util.go
index fb9a73d..7df68cb 100644
--- a/util.go
+++ b/util.go
@@ -15,11 +15,25 @@ func try(txt error) {
}
}
-// сокращение для вызова щенка и парсинга жсона
-func ujson(data string, output any) {
+func ujson(data string, output any) Error {
input, err := puppy(data)
- try(err)
- try(json.Unmarshal([]byte(input), output))
+ if err == nil {
+ try(json.Unmarshal([]byte(input), output))
+ }
+ return APIError(err)
+}
+
+type Error struct {
+ Reason string `json:"error"`
+ Error string `json:"errorDescription"`
+ RAW []byte `json:"-"`
+}
+func APIError(inputError error) (err Error) {
+ if inputError != nil {
+ err.RAW = []byte(inputError.Error())
+ try(json.Unmarshal(err.RAW, &err))
+ }
+ return
}
/* REQUEST SECTION */