Can't you leverage the exit code for this?