Allow plain text exceptions for Alfred notification outputs
Created by: idpaterson
Adds an exception_format
arg to Workflow.run
to allow plain text exceptions for notification outputs with tests to verify the original and new format.
This morning a few users reported XML errors showing up in notifications that normally say something like "The task has been added." The API used by my workflow was tossing 503 Service Unavailable errors, exceptions for which were caught by alfred-workflow. However, the errors were being formatted for a script filter response when the code was actually running in a script action that provides plain text to a notification output, so users saw a notification with text <?xml version="1.0" encoding="utf-8"?>
.
This is a backwards-compatible, quick fix type of change. There may be a more appropriate or even automatic way to produce the correct output for the current context but for now this seems to be the easiest place to modify this behavior.
In my case the exact same code runs in a script filter and in a script action. Both are triggered by a bash script in Alfred, the latter providing a --commit
argument to the python script to signify that the user selected something that can be actioned. So, it is more convenient for me to specify this flag at the wf.run()
call where wf.args
is available than as a config setting when constructing the workflow.
After this change exceptions can be configured to appear in plain text when necessary: