Skip to content

Commit e8a5e62

Browse files
authored
Schema errors: HTTP status code must be between 400-599 (webrpc#197)
If someone defined HTTP 200 for a schema error, the webrpc clients wouldn't recognize it as an error. Instead, they'd treat the response body as a regular response data object.
1 parent a6758ac commit e8a5e62

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

schema/error.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func (s *Error) Parse(schema *WebRPCSchema) error {
3131
if s.Message == "" {
3232
return fmt.Errorf("schema error: message cannot be empty")
3333
}
34-
if s.HTTPStatus < 100 || s.HTTPStatus >= 600 {
35-
return fmt.Errorf("schema error: invalid HTTP status code '%v' for error type '%s' (must be number between 100-599)", s.HTTPStatus, s.Name)
34+
if s.HTTPStatus < 400 || s.HTTPStatus > 599 {
35+
return fmt.Errorf("schema error: invalid HTTP status code '%v' for error type '%s' (must be number between 400-599)", s.HTTPStatus, s.Name)
3636
}
3737

3838
// check for duplicate codes or names

0 commit comments

Comments
 (0)