Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 10 of 12 total |
Cannot raise an exception |
Thu, Sep 8 2016 5:45 AM | Permanent Link |
Peter | Win 10, D-XE8, EDB 2,23 Build 2.
I am trying to replicate what happens when a user attempts to login to the EDB database, and the Server (service or application) is turned off. Or the config files are not where they should be. I have had MadExcept installed, but I turned it off. I cannot get a squeek out of the exception handler - and as far as I know, I don't have any 'Ignore this type of exception' set. The code is in the FormShow event of the Login form... try DataModule.EDBSession1.Connected := True; except if (E is EEDBError) then begin if (EEDBError(E).ErrorCode = 1100) then // EDB_ERROR_CLIENTCONN <<< what unit????? begin // ShowTaskDlg('ENG_FAIL', 'UN_EXPECT', '', [cbOk], tiError, tfiInformation, MB_ICONHAND); // raise; raise Exception.CreateFmt('Failed to open database : ''%s''', [EEDBError(E).ErrorMsg]); end else ... I step into any of those lines (ShowTaskDlg or raise; or raise Exception) and the debugger shows that it is addressing the line, but no message appears outside of 3 messages in the IDE that correctly identify the problem. But those messages do not appear outside the IDE. It isn't an EDB problem, but I am at a loss to understand what is going on. If you have any tips on where I should look, or some sample generic error trapping that I could rely on, I would appreciate it. Regards Peter |
Thu, Sep 8 2016 7:00 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Peter,
<< If you have any tips on where I should look, or some sample generic error trapping that I could rely on, I would appreciate it. >> Is the code stepping into the line that raises the exception ? As for which unit for that constant: you want the edberror unit. Tim Young Elevate Software www.elevatesoft.com |
Thu, Sep 8 2016 7:34 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Peter
1. Have you tried compiling with debug DCUs (if that's possible) and tracing into them to see what happens? 2. Where does the code go if you keep tracing after the raise exception? 3. What happens if you put a button on the form and run the code in that? Roy Lambert |
Thu, Sep 8 2016 7:35 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
>Is the code stepping into the line that raises the exception ? From his post I'm assuming it is <<I step into any of those lines (ShowTaskDlg or raise; or raise Exception) and the debugger shows that it is addressing the line>> Roy |
Thu, Sep 8 2016 5:02 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< From his post I'm assuming it is >> Yeah, I asked the wrong question for what I wanted - what I meant to ask is, does the raise exception actually occur ? Tim Young Elevate Software www.elevatesoft.com |
Fri, Sep 9 2016 5:29 AM | Permanent Link |
Peter | I didn't mention that the LogOn form is created 'manually' in the DPR, after the DataModule is AutoCreated. I figured that it wouldn't make any difference, as both forms are within the Application block.
Sorry, flat out today, but I will get to it again next week. I gave up on the messagebox and now display the error message smack in the middle of the LogOn form, and disable various controls that would be available to the user if the Login had been successful. The following is the relevant part of the DPR, between the begin and end... frmSplash := TfrmSplash.Create(nil); frmSplash.Show; frmSplash.Refresh; Application.CreateForm(TDataMod, DataMod); frmSplash.Refresh; if Assigned(frmSplash) then frmSplash.Close; SResult := TfrmLogOn.Execute; // SResult var is declared right before 'begin' if SResult > '' then begin Application.Initialize; Application.CreateForm(TfrmMain, frmMain); frmMain.SParseMe := SResult; // I extract UserID, Name, Location etc from SParseMe Application.Run; // in the frmMain.FormShow event end else begin // user clicked cancel or System.Close, or database failed to be found if Assigned(DataMod) then DataMod.Destroy; end; Maybe these shenanigans explain why it behaves mysteriously - i.e. the debugger stepping into the 'raise' line but not showing a message when run outside the IDE. Regards, and thanks for your input. Peter |
Fri, Sep 9 2016 6:52 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Peter
>I didn't mention that the LogOn form is created 'manually' in the DPR, As they say in all the best pantos "OH NO IT ISN'T" at least it isn't unless the TfrmLogOn.Execute creates the form (for all I know it may do in more recent Delphis). I assume its somewhere in the .Execute function that the error should be raised. I do things in a similar way begin Application.Initialize; Application.CreateForm(Tdm, dm); Application.CreateForm(Tlu, lu); Application.CreateForm(TMainForm, MainForm); if FetchUser then begin Application.CreateForm(TMainForm, MainForm); Application.Run; end else begin lu.Free; dm.Free; end; FetchUser is a function defined in my logon form. A quick hint as well > if Assigned(frmSplash) then > frmSplash.Close; You can get rid of the first line. If frmSplash isn't assigned you've got bigger problems than an AV. Roy Lambert |
Sun, Sep 11 2016 9:38 PM | Permanent Link |
Peter | Roy
Yes, TfrmLogOn.Execute is a public class: class function Execute: string; It creates the form and shows it modally, then assembles the results of the user's selections into a concise delimited string that as you can see, is passed to the main form. > if Assigned(frmSplash) then Yes, just a touch of paranoia on my part there. Thanks for the input. If I ever find out why the exceptions weren't visible outside the IDE I will let you know, but I think that displaying the error message right on the logon form is probably better than a message box that user's frequently click through, without reading. Regards Peter |
Mon, Sep 12 2016 2:32 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Peter
Can you post the .execute code? Roy Lambert |
Wed, Sep 14 2016 9:00 PM | Permanent Link |
Peter | <<Can you post the .execute code?>>
I have been out of the office for a couple of days. The delimited string was necessary as there are multiple parameters that relate to the user's log in process. class function TfrmLogOn.Execute: string; begin // Execute returns this string IN DPR, which is passed to frmMain.SLogInData in DPR Result := ''; with TfrmLogOn.Create(nil) do try if ShowModal <> mrOK then Exit; Result := ESPUserUserID.AsString + '|' + ESPUserAccessLevel.AsString + '|' + ESPUserRoleID.AsString + '|' + ESPUserOpenPages.AsString + '|' + ESPUserUserName.AsString + '|' + ESPUserFullName.AsString + '|' + BoolToStr(ESPUserBackStage.AsBoolean) + '|' + VarToStr(cxImgCbxLoc.Properties.Items[cxImgCbxLoc.ItemIndex].Value) + '|' + cxImgCbxLoc.Properties.Items[cxImgCbxLoc.ItemIndex].Description + '|' + BoolToStr(ESPUserIsProv.AsBoolean) + '|' + ESPUserRoleName.AsString + '|' + ESPUserProvType.AsString; finally Free; end; end; Regards Peter |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Saturday, May 4, 2024 at 09:18 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |