Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vildan-valeev committed Dec 30, 2023
1 parent 4f75d1b commit d28802e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 5 additions & 5 deletions dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ func (d *Dispatcher) autoSetting(ctx context.Context) error {
}

func (d *Dispatcher) check(r APIResponseUpdate) (err error) {
switch r.Failed {
case 0:
switch {
case r.Failed == 0:
d.opts.Ts = r.Ts
case 1:
case r.Failed == 1:
d.opts.Ts = r.Ts
case 2:
case r.Failed == 2:
err = d.updateServer(false)
case 3:
case r.Failed == 3:
err = d.updateServer(true)
default:
log.Println("Dispatcher update check", err)
Expand Down
11 changes: 8 additions & 3 deletions requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ func SendGetRequest(url string) ([]byte, error) {
}

func check(r Response) error {
//e := r.Base()
//log.Println("API ERROR:", e.Code, e.Message)
return nil
e := r.Base()
switch e.Code {
case 0:
return nil
// TODO: add another codes https://vk.com/dev/errors
default:
return e
}
}

0 comments on commit d28802e

Please sign in to comment.