mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-27 04:07:08 +00:00
fix(api): use not found status code when appropriate (#6885)
- Use a 404 error when the issue not found instead of returning an internal server error. - Resolves #4005 - Added integration test. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6885 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: ThomasBoom89 <thomasboom89@noreply.codeberg.org> Co-committed-by: ThomasBoom89 <thomasboom89@noreply.codeberg.org>
This commit is contained in:
parent
ab69057327
commit
5feca875ea
4 changed files with 119 additions and 8 deletions
|
@ -157,6 +157,17 @@ type swaggerAPIRepoArchivedError struct {
|
|||
Body APIRepoArchivedError `json:"body"`
|
||||
}
|
||||
|
||||
type APIInternalServerError struct {
|
||||
APIError
|
||||
}
|
||||
|
||||
// APIInternalServerError is an error that is raised when an internal server error occurs
|
||||
// swagger:response internalServerError
|
||||
type swaggerAPIInternalServerError struct {
|
||||
// in:body
|
||||
Body APIInternalServerError `json:"body"`
|
||||
}
|
||||
|
||||
// ServerError responds with error message, status is 500
|
||||
func (ctx *APIContext) ServerError(title string, err error) {
|
||||
ctx.Error(http.StatusInternalServerError, title, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue