-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32c934e
commit 47765cb
Showing
10 changed files
with
122 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package twitter | ||
|
||
import ( | ||
"github.com/tidwall/gjson" | ||
) | ||
|
||
const ( | ||
ErrTimeout = 29 | ||
ErrDependency = 0 | ||
ErrExceedPostLimit = 88 | ||
ErrOverCapacity = 130 | ||
) | ||
|
||
func CheckApiResp(body []byte) error { | ||
errors := gjson.GetBytes(body, "errors") | ||
if !errors.Exists() { | ||
return nil | ||
} | ||
|
||
codej := errors.Get("0.code") | ||
code := -1 | ||
if codej.Exists() { | ||
code = int(codej.Int()) | ||
} | ||
return NewTwitterApiError(code, string(body)) | ||
} | ||
|
||
type TwitterApiError struct { | ||
Code int | ||
raw string | ||
} | ||
|
||
func (err *TwitterApiError) Error() string { | ||
return err.raw | ||
} | ||
|
||
func NewTwitterApiError(code int, raw string) *TwitterApiError { | ||
return &TwitterApiError{Code: code, raw: raw} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters