mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-20 23:46:49 +00:00
Return 404 if pipeline not exist and handle 404 errors in WebUI (#1627)
This commit is contained in:
parent
1947408eba
commit
7e3bf2202c
3 changed files with 12 additions and 1 deletions
|
@ -101,7 +101,7 @@ func GetPipelines(c *gin.Context) {
|
||||||
c.AbortWithStatus(http.StatusNotFound)
|
c.AbortWithStatus(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.AbortWithStatus(http.StatusInternalServerError)
|
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, pipelines)
|
c.JSON(http.StatusOK, pipelines)
|
||||||
|
@ -123,6 +123,10 @@ func GetPipeline(c *gin.Context) {
|
||||||
|
|
||||||
pl, err := _store.GetPipelineNumber(repo, num)
|
pl, err := _store.GetPipelineNumber(repo, num)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, types.RecordNotExist) {
|
||||||
|
c.AbortWithStatus(http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,10 @@ const i18n = useI18n();
|
||||||
|
|
||||||
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
||||||
apiClient.setErrorHandler((err) => {
|
apiClient.setErrorHandler((err) => {
|
||||||
|
if (err.status === 404) {
|
||||||
|
notify({ title: i18n.t('errors.not_found'), type: 'error' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
notify({ title: err.message || i18n.t('unknown_error'), type: 'error' });
|
notify({ title: err.message || i18n.t('unknown_error'), type: 'error' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
"not_found": "Whoa 404, either we broke something or you had a typing mishap :-/",
|
"not_found": "Whoa 404, either we broke something or you had a typing mishap :-/",
|
||||||
"back_home": "Back to home"
|
"back_home": "Back to home"
|
||||||
},
|
},
|
||||||
|
"errors": {
|
||||||
|
"not_found": "Server could not find requested object"
|
||||||
|
},
|
||||||
"time": {
|
"time": {
|
||||||
"tmpl": "MMM D, YYYY, HH:mm z",
|
"tmpl": "MMM D, YYYY, HH:mm z",
|
||||||
"weeks_short": "w",
|
"weeks_short": "w",
|
||||||
|
|
Loading…
Reference in a new issue