Posts: 1,136
Threads: 37
Joined: Mar 2018
Reputation:
30
Location: Limassol, Cyprus
Where are you calling UserSession.Initialize from?
Posts: 14
Threads: 3
Joined: Apr 2019
Reputation:
0
Location: USA
Hello Kudzu,
Thank you for the reply.
In the IWServerControllerBaseNewSession event.
if GSessions.IsValidSession(ASession) then
begin
ASession.Data := TIWUserSession.Create(nil, ASession);
UserSession.Initialize;
end;
A mainform is set by default.
In the IWServerControllerBaseGetMainForm event I have to test for parameters and if valid, assign a different form and serve up a pdf document that is stored in blob field. If the params are valid but the doc does not exist then I TerminateAndRedirect with a message. If no params or the params are not valid then they are ignored and the default mainform is displayed.
Thank you for your assistance!
Craig
Posts: 14
Threads: 3
Joined: Apr 2019
Reputation:
0
Location: USA
Hi Jose,
I had looked at and tested that demo. Same issue... you get a blank page if the exception occurs within the servercontroller. Simple test is to Raise Create.Exception('test') in the newsession event right after the UserSession is created.
Thanks,
Craig
Posts: 1,136
Threads: 37
Joined: Mar 2018
Reputation:
30
Location: Limassol, Cyprus
IWServerControllerBaseNewSession
There were some changes after IW12. This event doesn't necessarily happen within the flow that you think it does or the same way as 12.
If the demo doesn't show what you need, let us know and we can look further to help you achieve what you desire.
Posts: 14
Threads: 3
Joined: Apr 2019
Reputation:
0
Location: USA
Hi Kudzu,
What I need is to be able to display our Custom Error in HTML window to user. Whether this occurs as an exception via the UserSession object, ServerConroller object or a form. We want to maintain consistancy. I have a workaround, though it just does not seem like the proper way. I can't use the ServerController.OnException because if that is assigned it bypasses the form (even when Handled is true).
So this ends up a blank screen. Can't TerminateAndRedirect there also it just stays blank.
The workaround is to test for exception when creating UserSession and Initilization if so, store the E.message to ServerController public property ErrorMsg and test for non-empty in creation of form. If so, then webApplication.terminate and Raise new execption with the ErrorMsg value and reset ErrorMsg to emptystr.
This still leaves holes though and is not a complete solution.
Thanks,
Craig
Posts: 2,174
Threads: 184
Joined: Mar 2018
Reputation:
79
Location: Auckland, New Zealand
Is this exception being raised when creating a new session?
I'm failing to reproduce this. Do you have a test case?
Posts: 14
Threads: 3
Joined: Apr 2019
Reputation:
0
Location: USA
Hi Alexandre,
In my case:
<code>
procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication);
begin
if GSessions.IsValidSession(ASession) then
begin
ASession.Data := TIWUserSession.Create(nil, ASession);
UserSession.Initialize; // most likely it will occur here due to invalid connectionname, sql access denied, etc...
end;
end;
</code>
In your Demo SubclassingExceptionRenderer :
<code>
procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication);
begin
ASession.Data := TIWUserSession.Create(nil);
raise Exception.Create('test Error Message'); // no message appears and the browser is blank
end;
</code>
Thank you,
Craig