What feature would you like, or what problem are you facing?
I think that it would be great it we could get some more output on the console when AutoIt crashes. For example, adding the 0x hex code and NTSTATUS description. This would be much more beneficial when troubleshooting issues with a script.
For example, we currently get something like:
AutoIt3 ended. rc:-1073740771
What's your proposed solution?
But instead, it would be awesome if we could get:
AutoIt3 ended. rc:-1073740771 [0xC000041D] An unhandled exception was encountered during a user callback.
The original _WinAPI_GetErrorMessage() function from the standard UDF set fails on the majority of error code lookups because it was lacking FORMAT_MESSAGE_FROM_HMODULE and the handle for ntdll.dll. So I've fixed that below:
#include <WinAPI.au3>
Local $iExample1 = -1073741819
Local $iExample2 = -1073740771
Local $iExample3 = -2147024894
; Example outputs
ConsoleWrite('AutoIt3 ended. rc:' & $iExample1 & ' [0x' & Hex($iExample1, 8) & '] ' & _WinAPI_GetErrorMessage_fixed($iExample1) & @CRLF)
ConsoleWrite('AutoIt3 ended. rc:' & $iExample2 & ' [0x' & Hex($iExample2, 8) & '] ' & _WinAPI_GetErrorMessage_fixed($iExample2) & @CRLF)
ConsoleWrite('AutoIt3 ended. rc:' & $iExample3 & ' [0x' & Hex($iExample3, 8) & '] ' & _WinAPI_GetErrorMessage_fixed($iExample3) & @CRLF)
Func _WinAPI_GetErrorMessage_fixed($iCode, $iLanguage = 0, Const $_iCallerError = @error, Const $_iCallerExtended = @extended)
Local $hModule = _WinAPI_GetModuleHandle('ntdll.dll')
Local $aCall = DllCall('kernel32.dll', 'dword', 'FormatMessageW', 'dword', BitOR($FORMAT_MESSAGE_FROM_SYSTEM, $FORMAT_MESSAGE_IGNORE_INSERTS, $FORMAT_MESSAGE_FROM_HMODULE), 'ptr', $hModule, 'dword', $iCode, _
'dword', $iLanguage, 'wstr', '', 'dword', 4096, 'ptr', 0)
If @error Or Not $aCall[0] Then Return SetError(@error, @extended, '')
; If Not $aCall[0] Then Return SetError(1000, 0, '')
Return SetError($_iCallerError, $_iCallerExtended, StringRegExpReplace($aCall[5], '[' & @LF & ',' & @CR & ']*\Z', ''))
EndFunc ;==>_WinAPI_GetErrorMessage_fixed
Screenshots
No response
Do you want to work on this issue/improvement?
Maybe
Any additional context?
No response
What feature would you like, or what problem are you facing?
I think that it would be great it we could get some more output on the console when AutoIt crashes. For example, adding the 0x hex code and NTSTATUS description. This would be much more beneficial when troubleshooting issues with a script.
For example, we currently get something like:
AutoIt3 ended. rc:-1073740771What's your proposed solution?
But instead, it would be awesome if we could get:
AutoIt3 ended. rc:-1073740771 [0xC000041D] An unhandled exception was encountered during a user callback.The original _WinAPI_GetErrorMessage() function from the standard UDF set fails on the majority of error code lookups because it was lacking FORMAT_MESSAGE_FROM_HMODULE and the handle for ntdll.dll. So I've fixed that below:
Screenshots
No response
Do you want to work on this issue/improvement?
Maybe
Any additional context?
No response