I haven't had time yet, but I will try this weekend.

------ Original Message ------
From "Lukasz Lenart" <lukaszlen...@apache.org>
To "Struts Developers List" <dev@struts.apache.org>
Date 2/9/2024 9:18:45 AM
Subject Re: [7.0.0-M3] Error message

Have you found a solution to this problem? I can take a look during the weekend

pon., 5 lut 2024 o 16:51 Burton Rhodes <burtonrho...@gmail.com> napisaƂ(a):

 When catching a FileUploadException in the
 AbstractMultiPartRequest.parse() method, if the final "else" is reached,
 the default message
 "struts.messages.upload.error.FileUploadException=Error uploading: {0}!"
 (struts-messages.properties) always displays the "{0}" instead of
 replacing it with the actual filename.  In looking at the code, it might
 be difficult to bubble up the filename from the source of the exception,
 but that would be the preferred solution.  Otherwise, it might make
 sense to change the default upload error message without the {0}
 parameters (e.g. "Error uploading the file", or "Error parsing the
 request."). Thoughts?


 [AbstractMultiPartRequest.java]

      public void parse(HttpServletRequest request, String saveDir) throws
 IOException {
          try {
              processUpload(request, saveDir);
          } catch (FileUploadException e) {
              LOG.debug("Request exceeded size limit!", e);
              LocalizedMessage errorMessage;
              if (e instanceof FileUploadByteCountLimitException ex) {
                  errorMessage = buildErrorMessage(e, new Object[]{
                          ex.getFieldName(), ex.getFileName(),
 ex.getPermitted(), ex.getActualSize()
                  });
              } else if (e instanceof FileUploadFileCountLimitException
 ex) {
                  errorMessage = buildErrorMessage(e, new Object[]{
                          ex.getPermitted(), ex.getActualSize()
                  });
              } else if (e instanceof FileUploadSizeException ex) {
                  errorMessage = buildErrorMessage(e, new Object[]{
                          ex.getPermitted(), ex.getActualSize()
                  });
              } else if (e instanceof FileUploadContentTypeException ex) {
                  errorMessage = buildErrorMessage(e, new Object[]{
                          ex.getContentType()
                  });

 // FINAL ELSE
              } else {
                  errorMessage = buildErrorMessage(e, new Object[]{});
              }

              if (!errors.contains(errorMessage)) {
                  errors.add(errorMessage);
              }
          } catch (IOException e) {
              LOG.debug("Unable to parse request", e);
              LocalizedMessage errorMessage = buildErrorMessage(e, new
 Object[]{});
              if (!errors.contains(errorMessage)) {
                  errors.add(errorMessage);
              }
          }
      }


 ---------------------------------------------------------------------
 To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
 For additional commands, e-mail: dev-h...@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org

Reply via email to