mirror of
https://git.macaw.me/skunky/devianter.git
synced 2025-04-28 12:05:07 +03:00
ошибки
This commit is contained in:
parent
4487cdcbe9
commit
b3c99749f1
5 changed files with 46 additions and 31 deletions
22
util.go
22
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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue