diff --git a/bot_raw.go b/bot_raw.go index a66f6211..60c506cb 100644 --- a/bot_raw.go +++ b/bot_raw.go @@ -331,7 +331,10 @@ func extractOk(data []byte) error { RetryAfter: int(retryAfter.(float64)), } default: - err = fmt.Errorf("telegram: %s (%d)", e.Description, e.Code) + err = &Error{ + Code: e.Code, + Description: e.Description, + } } return err diff --git a/bot_raw_test.go b/bot_raw_test.go index d935a6bb..377e029a 100644 --- a/bot_raw_test.go +++ b/bot_raw_test.go @@ -107,6 +107,15 @@ func TestExtractOk(t *testing.T) { err: ErrGroupMigrated, MigratedTo: -100123456789, }, extractOk(data)) + + data = []byte(`{ + "ok": false, + "error_code": 400, + "description": "Bad Request: can't parse entities: Can't find end tag corresponding to start tag \"b\"" + }`) + assert.Equal(t, &Error{Code: 400, Description: `Bad Request: can't parse entities: Can't find end tag corresponding to start tag "b"`}, + extractOk(data)) + } func TestExtractMessage(t *testing.T) {