madExcept Settings

delphi package - automated exception handling
Post Reply
costab
Posts: 21
Joined: Thu Jan 09, 2014 3:02 am

madExcept Settings

Post by costab »

Hello:

Revisiting madExcept after 1+ years. I posted this message: viewtopic.php?f=4&t=27774. I am interested in the same topic about the settings.

Basically, we have two environments, production and test. What's the pattern for handling different ME settings for different environments, while leaving the executable to be the same? Ideally I was thinking that the settings would be stored in the registry or in a text file and the setup program used to install our app would create the right settings based on the environment (the setup is aware of the environment; the application might also be made aware of the environment). Then at runtime the app reads these settings from the file/registry.

In the other post you pointed me to http://help.madshi.net/MESettings.htm#MESettings. Do you have a sample on how to change settings at runtime? Or is it as simple as:

Code: Select all

MESettings.HttpServer := '...';
MESettings.HttpAccount := '....';
If it is, what is the best place to override the ME settings? In the project?

Thank you!
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: madExcept Settings

Post by madshi »

Yes, it's as easy as that, although I do recommend using "with MESettings() do begin ... end", because MESettings() is a function creates a new dynamic interface, so calling it only once is better for performance.

I'd suggest to change all the settings somewhere in the initialization section of your project. Could be some unit's "initialization" block, or the start of the project file's (dpr) block. Of course you can also do it in your main form's OnCreate method, but that's rather late in the game. The earliest possible time would be some unit's initialization section.

Do you need to change the assistants at runtime, too? That's a bit more complicated...
costab
Posts: 21
Joined: Thu Jan 09, 2014 3:02 am

Re: madExcept Settings

Post by costab »

Thanks for your reply. I don't know what the assistants do. I have to read more...

I have one more question for you. So far I've developed/tested our app without madExcept. Using madExcept is an old idea I resurrected because the users often don't report crashes. We are reaching the user testing phase. Based on your experience, is adding madExcept to the project at this stage ok? I guess I am trying to asses the impact of using the library on the application itself. I personally think it should be fine, but I wonder whether I should wait until the next development cycle and use it for a while during development before going into the next iteration of user testing.

Thanks again.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: madExcept Settings

Post by madshi »

Most users are using madExcept from day one of the project and never stop using it. I see no reason why you should not use it in any phase during development. It should not affect performance or stability if your program doesn't crash. And if it does crash, do you ever *not* want to get a detailed report about such a crash?

Just my 2 cents, though. Personally, I'm always enabling madExcept for every of my own projects.
costab
Posts: 21
Joined: Thu Jan 09, 2014 3:02 am

Re: madExcept Settings

Post by costab »

Agreed.

Today I tried ME on our application. It is quite a big database application that accesses an Oracle database via TClientDataSet objects. What I am finding is that in certain scenarios the app now displays the MD default error dialog where before it simply showed a message box. I haven't customize it yet, I just wanted to see what happens out-of-the-box when I do different things in the application. For instance, if the user tries to save a row and a required field doesn't have a value the app shows the ME default error dialog. A EDatabaseError is thrown in this case. I added the class to the exception filter to show a simple dialog box. This is good. There are other cases where different types of exceptions are thrown and ME should be configured to display a message box instead of the default ME error dialog. I find the process of identifying exceptions that are innocuous and for which simple message box would suffice (vs. let them go through to reach the ME layer) difficult. It's not obvious from the code what exceptions might be thrown by the dbexpress & others, and what makes sense to be let through to the ME layer. Maybe I am overthinking it.

Any thoughts?

Thank you!
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: madExcept Settings

Post by madshi »

The filter in the madExcept settings dialog is only for classes. If you find other criteria by which to differ crashes from user errors then you can do that in a little "RegisterExceptionHandler()" exception handler in code.

Another option is the following: Try settings the bottom right combo box in the "exception filter" settings tab to "show msg box with detail button" instead of "show full exception box". This might work for both crashes and simple user errors. If you do that, I'd suggest to also change the "except box - exception message" in the "custom strings" settings tab to "%exceptMsg%" instead of "An error occurred in the application".
costab
Posts: 21
Joined: Thu Jan 09, 2014 3:02 am

Re: madExcept Settings

Post by costab »

Hello:

A few more questions:

1. Can madExcept save the screenshots along with the bugreport? I can imagine that they could be saved as png files in the same folder and use some kind of numbering scheme.

I am thinking of displaying just a simple exception message in case of exceptions, even without the Details button, but I want madExcept to save the bugreport and the screenshot.

2. If the user doesn't have the permission to write in the application folder (the users are not local admins), where is the bug report saved in case I specify just the file name? Can the file be saved somewhere under the user's profile? I want the user to do as little as possible and save the bugreport file under a standard location. Do you support referencing environment variables in the file name? Example: %home%\AppName\BugReports\bugreport.

3. Can madExcept write to the EventLog instead of or in addition to a file?

Thank you
Last edited by costab on Fri Dec 11, 2015 12:13 am, edited 2 times in total.
costab
Posts: 21
Joined: Thu Jan 09, 2014 3:02 am

Re: madExcept Settings

Post by costab »

Re: 2. I tried %USERPROFILE%\bugreport and it creates a folder named %USERPROFILE% in the same directory as the exe.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: madExcept Settings

Post by madshi »

costab wrote:1. Can madExcept save the screenshots along with the bugreport? I can imagine that they could be saved as png files in the same folder and use same king of numbering scheme.
Not by itself, but it should be easy enough for you to implement by using madExcept's "except action" handlers (which notify you when the bug report is saved) and madExcept's screenshot interface. More details see "RegisterExceptActionHandler()" in the documentation.
costab wrote:2. If the user doesn't have the permission to write in the application folder (the users are not local admins), where is the bug report saved in case I specify just the file name? Can the file be saved somewhere under the user's profile? I want the user to do as little as possible and save the bugreport file under a standard location. Do you support referencing environment variables in the file name? Example: %home%\AppName\BugReports\bugreport.
See here for supported %% variables:

http://help.madshi.net/madExceptSettings10.htm

I think by default, if the exe folder is not writable, it writes to %userappdata% instead, or something like that.
costab wrote:3. Can madExcept write to the EventLog instead of or in addition to a file?
Same answer as 1.
costab
Posts: 21
Joined: Thu Jan 09, 2014 3:02 am

Re: madExcept Settings

Post by costab »

Thank you for the pointer to the settings.

Another question. I want each bug report to be saved in its own file and make the date/time part of the bugreport name. I tried this: %userappdata%\MyApp\bugreport_%datetime%.txt, but it doesn't work, I guess because of the characters in the time portion. This works: %userappdata%\MyApp\bugreport_%date%.txt. I guess I could go with this for now but I would like to know if there is anything that could be done to save the bugreport in a standalone file.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: madExcept Settings

Post by madshi »

Sure, in your exception handler simply change "exceptIntf.BugReportFile".
Post Reply