mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-15 03:42:15 +01:00
chore(pdfengines): better custom error message if invalid args
This commit is contained in:
@@ -270,16 +270,6 @@ func EncryptPdfStub(ctx *api.Context, engine gotenberg.PdfEngine, userPassword,
|
||||
for _, inputPath := range inputPaths {
|
||||
err := engine.Encrypt(ctx, ctx.Log(), inputPath, userPassword, ownerPassword)
|
||||
if err != nil {
|
||||
if errors.Is(err, gotenberg.ErrPdfEngineEncryptionPasswordsNotSupported) {
|
||||
return api.WrapError(
|
||||
err,
|
||||
api.NewSentinelHttpError(
|
||||
http.StatusBadRequest,
|
||||
"Invalid form data: both 'userPassword' and 'ownerPassword' form fields must be provided and different",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
return fmt.Errorf("encrypt PDF '%s': %w", inputPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user