feat: enhance Safew error handling and polling mechanism
- Added error_msg field to safewAPIResponse for better error descriptions. - Updated safewErrorDescription function to include error_msg in the output. - Introduced a new test to verify that error messages are included in Safew error descriptions. - Improved the polling mechanism in the Watcher to handle conflicts and ensure no overlapping polls occur.
This commit is contained in:
@@ -99,6 +99,13 @@ func TestPollGroupChatsSuccess(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSafewErrorDescriptionIncludesErrorMsg(t *testing.T) {
|
||||
got := safewErrorDescription([]byte(`{"ok":false,"description":"BAD_REQUEST","error_msg":"Conflict: terminated by other getUpdates request"}`))
|
||||
if !strings.Contains(got, "Conflict") {
|
||||
t.Fatalf("got %q, want error_msg", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPollGroupChatsUnauthorized(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
|
||||
Reference in New Issue
Block a user