Return 404 if pipeline not exist and handle 404 errors in WebUI (#1627)

This commit is contained in:
6543 2023-03-17 02:10:51 +01:00 committed by GitHub
parent 1947408eba
commit 7e3bf2202c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -101,7 +101,7 @@ func GetPipelines(c *gin.Context) {
c.AbortWithStatus(http.StatusNotFound)
return
}
c.AbortWithStatus(http.StatusInternalServerError)
_ = c.AbortWithError(http.StatusInternalServerError, err)
return
}
c.JSON(http.StatusOK, pipelines)
@ -123,6 +123,10 @@ func GetPipeline(c *gin.Context) {
pl, err := _store.GetPipelineNumber(repo, num)
if err != nil {
if errors.Is(err, types.RecordNotExist) {
c.AbortWithStatus(http.StatusNotFound)
return
}
_ = c.AbortWithError(http.StatusInternalServerError, err)
return
}

View file

@ -33,6 +33,10 @@ const i18n = useI18n();
// eslint-disable-next-line promise/prefer-await-to-callbacks
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' });
});

View file

@ -20,6 +20,9 @@
"not_found": "Whoa 404, either we broke something or you had a typing mishap :-/",
"back_home": "Back to home"
},
"errors": {
"not_found": "Server could not find requested object"
},
"time": {
"tmpl": "MMM D, YYYY, HH:mm z",
"weeks_short": "w",