November Happy Hour will be moved to Thursday December 5th.

Throw failure manually - Episerver job message

Vote:
 

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?

Thanks

#229959
Edited, Oct 27, 2020 20:02
Vote:
 

Hi Sean

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

#229960
Oct 27, 2020 20:20
Vote:
 

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");
}

#229962
Oct 27, 2020 20:23
Vote:
 

Great, thanks to both of you!

#229963
Oct 27, 2020 20:37
Vote:
 

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. 

#229989
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.