Jump to content

Do "Post Notifications" still appear if a script failed to run, such as when the API is down?


Recommended Posts

I've got a workflow for adding tasks to a todo website. It basically just sends a POST request to an API. When the task is added, I get a Post Notification telling me so.

 

If the website is down when I run this workflow to add a task, then would the Post Notification still appear? Ideally, of course, either the notification does NOT appear if the site is down, so I know something went wrong; or better yet, it would tell me that something went wrong when it tried to send a POST request to the API.

Link to comment

I've got a workflow for adding tasks to a todo website. It basically just sends a POST request to an API. When the task is added, I get a Post Notification telling me so.

 

If the website is down when I run this workflow to add a task, then would the Post Notification still appear? Ideally, of course, either the notification does NOT appear if the site is down, so I know something went wrong; or better yet, it would tell me that something went wrong when it tried to send a POST request to the API.

 

I moved the thread to Workflow Help & Questions as you'll get more help here than in the general discussion forum. :)

Link to comment

I've got a workflow for adding tasks to a todo website. It basically just sends a POST request to an API. When the task is added, I get a Post Notification telling me so.

 

If the website is down when I run this workflow to add a task, then would the Post Notification still appear? Ideally, of course, either the notification does NOT appear if the site is down, so I know something went wrong; or better yet, it would tell me that something went wrong when it tried to send a POST request to the API.

Alfred will show the notification regardless of whether your script exits cleanly or not (you might be trying to show an error message, after all).

However, it's possible that the notification won't be shown depending on the configuration. If you've checked the box "Only show if passed in argument has content" in the Post Notification options, then Alfred won't show the notification if your script doesn't send any output to STDOUT (i.e. it doesn't print/echo anything).

So if your script fails and exits before it prints anything (error messages go to STDERR, not STDOUT), no notification will be shown.

What I normally do in these situations is catch any exception and show an error message in the notification. I always find it a bit confusing when things fail silently, so I try to avoid my own software doing so.

 

Link to comment

Personally I think I'd rather have NO notification appear if something goes wrong, because when a notification appears, I rarely look at it. I usually perform an action, and if a notification appears within a second or two and I can see it in my peripheral vision, then that's just confirmation that what I did actually worked.

 

So I don't mind if when something goes wrong, that the notification does not appear.

 

The workflow and script I'm using now, I didn't write it; it's written in Bash and Python. From what I can tell, from the last line, it gets the response from a POST command and prints out its "content" field. Hopefully that field is therefore non-existent/empty when the site is down, so that the notification does not appear (I've set the notifications to only appear when {query} exists).

Link to comment

You don't have to show a notification if something goes wrong, but Alfred does give you the choice.

 

I expect that your script will fail and exit if the server can't be reached. I can't say for sure, as I don't have the source code, but as a rule you'd need to take steps to stop your script crashing at that point if the connection fails.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...