mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-08 00:22:14 +01:00
fix(pdfengines): read metadata better webhook error - fixes #1148
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user