Re: [7.0.0-M3] Error message

Lukasz Lenart <[email protected]>
Newsgroups gmane.comp.jakarta.struts.devel
Message-ID <CAMopvkN-FgjdXYFjBwV_Hbj=B1hxNejnAjk-jWW-jeT=Z4zCMQ@mail.gmail.com>
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 <[email protected]> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.