Problem/Motivation

FileUploadHandler::handleFileUpload() throws FileExistsException when the destination file exists and FileException for an invalid filename. Callers must catch these separately from checking violations on the result object, mixing two error-reporting styles for failures caused by user input.

Steps to reproduce

Proposed resolution

Add getErrors() to FileUploadResult, separate from getViolations(). handleFileUpload() catches FileExistsException and FileException internally and adds them to the result's errors instead of throwing. InvalidStreamWrapperException, FileWriteException, and LockAcquiringException keep throwing, since they reflect misconfiguration or environment failures rather than user input.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3619417

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kim.pepper created an issue. See original summary.

nicxvan made their first commit to this issue’s fork.

nicxvan changed the visibility of the branch 3619417--return-fileexistsexception to hidden.

kim.pepper changed the visibility of the branch 3619417-exception to hidden.

kim.pepper’s picture

Status: Active » Needs review

This may have gone out of scope from the original issue summary. I wanted to avoid rendering messages in FormFileUploader, and leave that to calling code.

kim.pepper’s picture

@nicxvan I had a chat with @amateescu in Rotterdam, and he agrees this kind of change can still go into 12.x beta. If we get it to RTBC I will ping him.

smustgrave’s picture

This something that needs a change record the way it's collecting errors now into an array?