Pushing errors back to MODX Upload dialogue box

I have a few snippets that run on upload events to do things like generate image thumbnails of PDFs for display etc.

The following questions relate to the MODX 2.8 family.

  1. Does anyone know if there’s a way to return errors from those snippets such that they turn up in the ‘State’ column of the upload dialogue box as red errors? If something goes wrong I’m currently logging that to a file but I’d love to be able to return meaningful errors to the user.

  2. is there a timeout this box uses to wait for a response? I’ve done a quick scan of the code I can find and can’t turn anything up. I have a process I’ve just run on a large (30mb/63 page PDF) upload and the interface is returning a non-descript ‘Error’ dialogue box that pops over the upload dialogue, but a few minutes later the result is where it should be (ie the script hasn’t failed nor returned a fail, but something has decided it’s time for an ‘Error’ alert with no further info. Any wisdom on what I can do about that?

On what events exactly?

If you have a plugin that runs on the event OnFileManagerUpload,

you get access to the “source” that is passed by reference. So you should be able to do something like this in your plugin:

$source->addError('path','some error message');