Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Show all _error information on error
#1
Is there some way to configure QM GUI to -- when an error occurs in my macro -- automatically print all the _error info to the output pane?

Now it just shows:
Code:
Copy      Help
Error (RT) in My First Macro:  failed.    ?"
I'd really like to see the line number. In fact I would like to see all the _error information.

Code:
Copy      Help
str s
err
,out "An error occurred"
,out s.format("Macro: %s" s.getmacro(_error.iid 1))
,out s.format("Line number: %d" _error.source)
,out s.format("Desc: %s" _error.description)
,out s.format("Code: %d" _error.code)
,out s.format("Place: %d" _error.place)
,out s.format("Line: %s" _error.line)

But I don't want to put this code in all of my macros. I know... I can create a function that contains this code. But can I register a global error handler so that all of my macros print this information without any special instructions added to each of my macros?

Do I have to add "atend MaybePrintErrorsOut" to all my macros?

Does QM come with a built-in function that will format _error into a nice report string for printing into dialog/stdout/logfile?

I was surprised that QM does not by default show a line number upon error. Usually to be user friendly there is a link you can click to jump the editor to the line Smile

But it's okay. I'm just curious.
#2
The best that is possible - to add "atend MaybePrintErrorsOut" to all macros.

Ideas for the future QM development: add "on error" trigger. Then the function would be called on error in all macros or in all that have specified parameters, etc. It would receive error info, and maybe even can change something, for example whether to end macro or continue...
#3
Okay. I just did not want to do things the "hard" way if something very easy was already in place. This atend solution is not bad and writing an error handler taught me some QM syntax anyway.

Nice for users to be able to plug in pre-built "Verbose Global Error Handler" when they are getting started and writing more errors that successes Smile
#4
I like the idea of being able to install a global error handler that can
- optionally format the error message and optionally print/log/alert it
- optionally set/return a value about whether the program should continue or halt

I guess the only concern is making sure local error handlers get preferred over the global error handler when local handlers exist.

Also script backwards compatibility. (Altho, if the global error handler did nothing by default, then it's the script author's problem if they install a global error handler that breaks their macro).
#5
The trigger probably will run when the macro is ending (can also add option to run when ends normally too) and will not be able to make to continue macro. But it could change what/if error info is displayed, whether to open the macro to show error, also can log to a file, measure time, notify somebody, restart, start other macro... Really useful, thank you for a good idea.
#6
Sounds nice.

Somehow I didn't notice this:

when you click the macro name in the error in the output panel it will jump the editor to the error line. That's good, and the main thing I was missing.

It seems obvious, but I guess I thought because the line number wasn't displayed, it wouldn't jump. But it does.


Attached Files Image(s)
   
#7
Hello All,
great thread. If a future enhanced error logging functionality is in the works, it would be great if it somehow contained the callstack as well. It's sometimes hard to figure out which is the caller, thread entry function, and steps along the way in a complicated exe!
Thanks again,
S


Quote:GetCallStack [str*cs] [flags] ;;flags: 1 no code, 2 no formatting
QM 2.3.5.
Gets function call stack
It is a multiline list of function names. The first is current function, then its caller, caller's caller and so on.
cs - receives results. If omitted or 0, displays in QM output.
flags:
1 Get only function names. By default also gets current statement code. In exe never gets code.
2 Get plain text. By default the text is formatted for QM output.


Forum Jump:


Users browsing this thread: 1 Guest(s)