symfony-cmf / media-bundle

UNMAINTAINED - Minimalistic interfaces to handle media in the context of the CMF
http://cmf.symfony.com/
30 stars 40 forks source link

handle file upload errors #82

Closed dbu closed 10 years ago

dbu commented 10 years ago
Q A
Bug fix? yes
New feature? no
BC breaks? yes
Deprecations? -
Tests pass? -
Fixed tickets #79
License MIT
Doc PR -

When uploading files through a form, there is no error handling. I thought we could use the upload file helper from the form type as well. This at least now gives a message that something went wrong and makes the upload file field marked as the field with error. however, it only gives the generic "invalid value" hint and does not show the ecxeption i throw. is there a way to better control that and give the exact error message like "file too big"?

rmsint commented 10 years ago

There should be a way indeed to show the exact error message.

In the past I managed to get a custom error message attached to a field using the Symfony\Component\Validator\ExecutionContext specifying the property path and violation. I think this is not what you want to do here, however I wonder if the form framework triggers this somewere for the upload field and how it passes then the error?

dantleech commented 10 years ago

@rmsint I think its not very DRY:

lsmith77 commented 10 years ago

ping

dbu commented 10 years ago

this is now ready to merge. we still only get the generic invalid value message, seems the message from the transformer can't get forwarded to the form output and we would need a validator. however i have no clue where and how we would do that, so lets merge this as its a big improvement already.

dbu commented 10 years ago

reverted the change in testing that created corebundle dependency and retriggered the build

dbu commented 10 years ago

okay, the tests seem to be a mess. but maybe i am just reveiling issues that went unnoticed before? would be great if somebody can sort this out for 1.1

lsmith77 commented 10 years ago

i really do not know this Bundle very well .. tests seem to be green now ..