From 443763372fbb41f6c0e512bd90d09830c42adcaf Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Wed, 11 Sep 2024 14:48:36 +0200 Subject: [PATCH] CAMEL-21201: camel-ftp - Enrich exception with FTP client error codes if failing to upload file --- .../apache/camel/component/file/remote/FtpOperations.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java index 43a29d10e43ef..8c827aa5ef4a1 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java @@ -710,6 +710,14 @@ public boolean storeFile(String name, Exchange exchange, long size) throws Gener clientActivityListener.onUploadComplete(endpoint.getConfiguration().remoteServerInformation(), name); } + if (!answer) { + Integer code = exchange.getIn().getHeader(FtpConstants.FTP_REPLY_CODE, Integer.class); + String status = exchange.getIn().getHeader(FtpConstants.FTP_REPLY_STRING, String.class); + if (code != null && status != null) { + throw new GenericFileOperationFailedException(code, status, "Error writing file [" + targetName + "]"); + } + } + return answer; }