How to access exception Error Message from action executed by a timer?

How to access exception Error Message from action executed by a timer?

  
Hello All,

In case, when exception is caught by Error Handler in context of request processing, the Error Message of the last exception will be in Session.ExceptionMessage

Is there a way to get access to exception Error Message from action executed by a timer (batch mode)?

Thanks,
Alex.
Hi Alex,

The best way for you to do it is to store the message in the database, similar to a log. That way you can read it later.

Another way you can get that message is in Service Center - it should be logged in the Error Log page at least (I don't recall if something is logged as well in the Timer log page, but I don't think so).

Let us know if this solution helps you!

Regards,

Paulo Tavares
Hello Paulo,

I am afraid my question was not clear.. let me ask in another way. 

Let's have ActionDispatcher executed by a TimerDispatcher.
ActionDispatcher calls Action1,  Action2, Action3.. Action n and has a error handler for user exception E.
Action1 raises user exception E with a message M1 text.
Action2 raises user exception E with a message M2 text.
Action3 raises user exception E with a message M3 text.
Action n raises user exception E with a message Mn text.

ActionDispatcher is also the action which writes into a log file..so it needs to get access to M1, M2, M3..Mn somehow to log them.
Is there a way ActionDispatcher can access the messages M1, M2, M3..Mn ?

If not, do you suggest that the way to proceed in this case would be to include logging code directly into  Action1,  Action2, Action3.. Action n?

Thanks,
Alex.
Hi Alex,

I am not sure I understand your scenario correctly, but if the Action dispatcher is executing several actions, will it keep on executing the next one even if an exception is raised? If not, well, it'll only need to access the exception for the last action, right? I would assume that's the case - i.e. Action 1 throws an exception, it is raised and caught by ActionDispatcher's Exception Handler, and handled there.

If that's the case, then maybe the exception is indeed in Session.ExceptionMessage, and all you would need to do is read it form there. I'm saying "maybe" because since it is not in the context of a web request, it might not be stored there... Then we'd have a problem :)

If, however, ActionDispatcher will keep on executing several actions, then yes, I would handle each error in each action. If you're trapping the exceptions in each action, then that's where you should do it.

I'm not sure I made my self clear, but let me know if this answers your question, or how we can improve these suggestions further!

Regards,

Paulo Tavares
Hello Paulo,

Thank you for clarification.. 

The question was: Is there a way ActionDispatcher can access the messages M1, M2, M3..Mn ?
As I understand your answer: no, there is no way. 

The platform supports the option to access the messages in Session.ExceptionMessage in context of HTTP requests, so it was logical to assume that similar approach should exist for batch (timer run) processes. 
As I could not find anything like that, I just wanted to ensure I do not miss anything.

Regards,
Alex.
Hi Alex,

Yes, as far as I know, the platform does not store a queue of exception messages, asides from them being logged in the Error Log, if we don't handle them.

However, this is my understanding of the problem, and there may be other people with different experiences who may have a solution for what you want to do. Even if I am moderately proficient and knowledgeable of the Agile Platform itself, I am not by any means the person who knows everything about it :) I may be overlooking something, or even I may just be plain wrong.

Cheers,

Paulo Tavares
You can access the error messages through the variable Session.ExceptionManager as you would in other situations.

I've attached an eSpace which clearly shows this: Dispatcher calls Action1, which raises UserException E with Message "M1" and it gets caught and logged to the table Messages. The default Entry point for the eSpace has a button to wake the timer and shows what's on the Message entity. Just hit the button, refresh after a while (may take a while for the Scheduler to actually run), and see M1 showing up.

Please note that when an exception is thrown and not caught by an action the application flow will be broken and you'll go to the exception handler. This means, in my eSpace, that Action2 will never run. If you want Action2 to run even after Action1 throws an error, you will have to catch the error on Action1 itself and not let it bubble up to Dispatcher, at which point Session.ExceptionMessage should be cleared. To circumvent this (and be able to pass on the error message even when an exception was thrown) you could create a pair of output parameters on the inner actions which are set when an exception is thrown: one indicating that an error occured (set to True on the handler) and one propagating the error message if it occured (set to the value of Session.ExceptionMessage on the handler).

Does this answer your question?
Ricardo,

Your clarification clears my confusion and as such "answers my question" - thank you a lot for follow up..
Apparently there must be something else that I have overlooked in my code that prevented my code from working in the same fasion as in your example. 

I BTW can't run your example for some reason.. after publishing the eSpace your attached, I get the bellow error when I open the space in a browser.
I have tried to re-import List_Navigation_GetStartIndex Action, recreated the screen, but it did not help.
What is wrong? How can this be fixed?

Thanks,
Alex.


There was an error processing your request:

'List_Navigation_GetStartIndex' Action is incompatible with the 'RichWidgets' eSpace definition. Please update it.

	
	'List_Navigation_GetStartIndex' Action is incompatible with the 'RichWidgets' eSpace definition. Please update it.
   at ssTimerEMTest.RsseSpaceRichWidgets.MssList_Navigation_GetStartIndex(HeContext heContext, String inParamListWidget, Boolean inParamRememberStartIndex, Int32 inParamStartIndexOverride, Int32& outParamStartIndex)
   at ssTimerEMTest.Functions.rssespacerichwidgets_ActionList_Navigation_GetStartIndex(HeContext heContext, String inParamListWidget, Boolean inParamRememberStartIndex, Int32 inParamStartIndexOverride)
   at ssTimerEMTest.Flows.FlowMainFlow.ScrnWebScreen2.Page_Load(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Please click back on your browser and try again or, if the error persists, please restart your session.