From 6051f67ddb1cfd77a34e8781c1c5f84c2cc4424b Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Mon, 8 Feb 2021 17:32:34 +0300 Subject: [PATCH] Restore checkFacebookError --- response.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/response.go b/response.go index 5740ff6..9a1206f 100644 --- a/response.go +++ b/response.go @@ -81,6 +81,21 @@ func (e QueryError) Error() string { return e.Message } +func checkFacebookError(r io.Reader) error { + var err error + + qr := QueryResponse{} + err = json.NewDecoder(r).Decode(&qr) + if err != nil { + return xerrors.Errorf("json unmarshal error: %w", err) + } + if qr.Error != nil { + return xerrors.Errorf("facebook error: %w", qr.Error) + } + + return nil +} + func getFacebookQueryResponse(r io.Reader) (QueryResponse, error) { qr := QueryResponse{} err := json.NewDecoder(r).Decode(&qr)