Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Throw failure manually - Episerver job message


Is there a way I can pass back a message from a job execution that will show up a "failure" message manually? There is a failure condition that I want to pass back in a certain situation, but I'm only aware of passing back a success message for a ScheduledJobBase job execute override. Is there a text lookup for the start of that string that would allow me to designate a failure?


Edited, Oct 27, 2020 20:02

Hi Sean

As far as I am aware, Episerver will only mark a job execution as failed, if the job throws an exception.

Oct 27, 2020 20:20

Yupp, what @stefan said. I just tested and that works. So throw a exception :)

public override string Execute()
     throw new Exception("This is a custom failure");

Oct 27, 2020 20:23

Great, thanks to both of you!

Oct 27, 2020 20:37

It is also important to know that never, ever throw an exception in an async method in your scheduled job. Those will not be catched by the scheduler, and will most likely crash your entire web app. 

Oct 28, 2020 9:07
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.