-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When we got panic, we responded with HTTP 200 but no right headers; this needs to be clarified. Fixed: - use HTTP 500 - Quesma should take responsibility and return JSON Before: ![Screenshot 2024-05-17 at 11 46 47](https://github.com/QuesmaOrg/quesma/assets/972989/04395b1f-b0b5-4a42-9b8c-9ea6aed5d7aa) After: ![Screenshot 2024-05-17 at 12 16 57](https://github.com/QuesmaOrg/quesma/assets/972989/8120e844-e7f7-4b6c-bc0b-509db54ec773)
- Loading branch information
Showing
4 changed files
with
73 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package queryparser | ||
|
||
import "encoding/json" | ||
|
||
func BadRequestParseError(err error) []byte { | ||
serialized, _ := json.Marshal(DashboardErrorResponse{ | ||
Error: Error{ | ||
RootCause: []RootCause{ | ||
{ | ||
Type: "parsing_exception", | ||
Reason: err.Error(), | ||
}, | ||
}, | ||
Type: "parsing_exception", | ||
Reason: err.Error(), | ||
}, | ||
Status: 400, | ||
}, | ||
) | ||
return serialized | ||
} | ||
|
||
func InternalQuesmaError(msg string) []byte { | ||
serialized, _ := json.Marshal(DashboardErrorResponse{ | ||
Error: Error{ | ||
RootCause: []RootCause{ | ||
{ | ||
Type: "quesma_error", | ||
Reason: msg, | ||
}, | ||
}, | ||
Type: "quesma_error", | ||
Reason: msg, | ||
}, | ||
Status: 500, | ||
}, | ||
) | ||
return serialized | ||
} | ||
|
||
type ( | ||
DashboardErrorResponse struct { | ||
Error `json:"error"` | ||
Status int `json:"status"` | ||
} | ||
Error struct { | ||
RootCause []RootCause `json:"root_cause"` | ||
Type string `json:"type"` | ||
Reason string `json:"reason"` | ||
Line *int `json:"line,omitempty"` | ||
Col *int `json:"col,omitempty"` | ||
} | ||
RootCause struct { | ||
Type string `json:"type"` | ||
Reason string `json:"reason"` | ||
Line *int `json:"line,omitempty"` | ||
Col *int `json:"col,omitempty"` | ||
} | ||
) |
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