fix(pdfengines): read metadata better webhook error - fixes #1148

This commit is contained in:
Julien Neuhart
2025-05-15 09:22:52 +02:00
parent 66317197b6
commit 9aaab97d6a
5 changed files with 48 additions and 24 deletions

View File

@@ -184,11 +184,21 @@ func webhookMiddleware(w *Webhook) api.Middleware {
// Call the next middleware in the chain.
err := next(c)
if err != nil {
if errors.Is(err, api.ErrNoOutputFile) {
errNoOutputFile := fmt.Errorf("%w - the webhook middleware cannot handle the result of this route", err)
handleAsyncError(api.WrapError(
errNoOutputFile,
api.NewSentinelHttpError(
http.StatusBadRequest,
"The webhook middleware can only work with multipart/form-data routes that results in output files",
),
))
return
}
// The process failed for whatever reason. Let's send the
// details to the webhook.
ctx.Log().Error(err.Error())
handleAsyncError(err)
return
}
@@ -197,7 +207,6 @@ func webhookMiddleware(w *Webhook) api.Middleware {
if err != nil {
ctx.Log().Error(fmt.Sprintf("build output file: %s", err))
handleAsyncError(err)
return
}
@@ -205,7 +214,6 @@ func webhookMiddleware(w *Webhook) api.Middleware {
if err != nil {
ctx.Log().Error(fmt.Sprintf("open output file: %s", err))
handleAsyncError(err)
return
}
@@ -221,7 +229,6 @@ func webhookMiddleware(w *Webhook) api.Middleware {
if err != nil {
ctx.Log().Error(fmt.Sprintf("read header of output file: %s", err))
handleAsyncError(err)
return
}
@@ -229,7 +236,6 @@ func webhookMiddleware(w *Webhook) api.Middleware {
if err != nil {
ctx.Log().Error(fmt.Sprintf("get stat from output file: %s", err))
handleAsyncError(err)
return
}
@@ -237,7 +243,6 @@ func webhookMiddleware(w *Webhook) api.Middleware {
if err != nil {
ctx.Log().Error(fmt.Sprintf("reset output file reader: %s", err))
handleAsyncError(err)
return
}