I have a timer job which is pretty standard. Like any timer job execution of it can sometimes fail. If this happens in job status (Central Admin) the timer job status is failed.

I would like to be able to catch this type of failure in my job definition and hookup a built in event, such as onFail or onError - is this type of thing possible?

  • Can you please specify which SharePoint version are you using? 2010 / 2007?
    – SPArcheon
    Nov 8, 2011 at 10:08
  • SharePoint 2010.
    – JL01
    Nov 8, 2011 at 23:15
  • Only thing that comes to mind is either: a) simulate the handler inside the timer job (if this is possible) and then force the timer job status as failed; b) force a second esecution of the timer job with the Retry job definition parameter; c) force the execution of another timer job using the new RunNow job definition method (and leaving the original job in a failed status). I know this isn't much, but at the moment nothing better comes to mind. I will try and search for a more elegant solution (I had a similar problem in the past, so I'm on the same boat here...)
    – SPArcheon
    Nov 9, 2011 at 9:26

1 Answer 1


I would suggest using a try { } catch { } block on your Execute function. In the catch I would have it record the error message to the ULS log (or email you if thats what you want) and then throw the exception.

The ensures you log and/or are notified of the failure but the failure is also seen on the timer job in Central Admin.

So, something like:

public override void Execute(Guid targetInstanceId)
        // Timer Job Code to Execute
    catch (Exception exception)
        // write to ULS or email
        throw exception;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.