Modify

Opened 7 years ago

Closed 4 years ago

Last modified 4 years ago

#3547 closed Feature Request (Completed)

@ErrorStdOut or $ErrorStdOut for /ErrorStdOut

Reported by: argumentum Owned by: Jpm
Milestone: 3.3.15.4 Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

to make a reserved variable, as is in the case of $CmdLineRaw, or a macro, to hold the output from "AutoIt Error", to be held in a similar variable, let's say $ErrorStdOut, to be available at OnAutoItExitRegister(), just as @exitMethod is there, maybe @ErrorStdOut or $ErrorStdOut can be available.

Attachments (0)

Change History (12)

comment:1 Changed 7 years ago by TicketCleanup

  • Version Other deleted

Automatic ticket cleanup.

comment:4 in reply to: ↑ 3 Changed 7 years ago by argumentum

Replying to mLipok:

Just as a reference/releated request:

Just as a reference, yes. Just in case, I'll make an argument
( I'd really like this request implemented )

https://www.autoitscript.com/trac/autoit/ticket/2488

what he asked for is nonsense in my view. OnAutoitExit() runs regardless.

https://www.autoitscript.com/trac/autoit/ticket/2919

what he asked for is already there. OK Exit 0, not OK Exit 1, that is the returned errorlevel
We can use the rest of the Exit from 2 upwards for our own expected errors.
@ExitCode should reflect that.
@ExitMethod is as it should be.

Therefore, these other 2 requests are not related to this one, other than is OnAutoitExit()
I hope that the request for an @ErrorStdOut is considered.

comment:5 Changed 7 years ago by argumentum

...and maybe a hash tag and/or Opt() for the suppression of the error GUI popup, as it would make sense, given the opportunity for error to be handled, if the given hash or Opt() is purposely declared in the script.
Just as after time a #NoTrayIcon was accepted as OK to have.

comment:6 Changed 6 years ago by argumentum

Found a topic in the forums where the MsgBox is intercepted, giving the opportunity to handle this from within the script.
https://www.autoitscript.com/forum/topic/143250-grab-runtime-errors-when-script-is-run-from-a-service/?do=findComment&comment=1009391

comment:7 Changed 4 years ago by argumentum

Opt("OnExitCode", 1)
from https://www.autoitscript.com/autoit3/docs/appendix/Exitcodes.htm
I've never seen it on any version that I can remember.

comment:8 Changed 4 years ago by Jpm

In fact the Opt() is Opt("SetExitCode", 1) not documented in the Help, just included in the Web doc.

comment:9 Changed 4 years ago by Jpm

  • Milestone set to 3.3.15.4
  • Owner set to Jpm
  • Resolution set to Completed
  • Status changed from new to closed

Added by revision [12345] in version: 3.3.15.4

comment:10 Changed 4 years ago by Jpm

I fixed the doc for "SetExitCode" option and I introduce 2 Functions to format th @ExitCode and the @ExitLethod
The best I can do without having Jon change the AutoIt code

Cheers

comment:11 Changed 4 years ago by argumentum

lol, thanks. I should have read more carefully before coding this:

Execute('Opt("SetExitCode", 1)') ; done within an Execute() until AU3Check.exe update in v3.3.15.4
OnAutoItExitRegister("__OnAutoItExit")

main()
Func main()
	OnAutoItExitRegister("__OnAutoItExit")
	Local $n, $a[6] = [5, 5, 4, 3, 2, 1]
	For $n = 1 To 100
		ToolTip('..crashing in ' & $a[$n], 50, 50, "CrashTest")
		ConsoleWrite('..crashing in ' & $a[$n] & @CRLF)
		Sleep(500)
	Next
EndFunc   ;==>main
Func __OnAutoItExit()
	Local $sExitMethod
	Switch @exitMethod
		Case 0
			$sExitMethod = "closed by natural closing."
		Case 1
			$sExitMethod = "closed by Exit function."
		Case 2
			$sExitMethod = "closed by clicking on exit of the systray."
		Case 3
			$sExitMethod = "closed by user logoff."
		Case 4
			$sExitMethod = "closed by Windows shutdown."
		Case Else
			$sExitMethod = "closed by no clue."
	EndSwitch
;~     MsgBox(262144, @ScriptName, "I could do something with the error from here", 2)

	MsgBox(262144, @ScriptName, "Oh !, wait, we now can  =)" & @CR & _
			@CR & "The error was: " & Hex(@exitCode) & _
			@CR & "Meaning: """ & FatalErrormessageFromExitCode(@exitCode) & """" & _
			@CR & "and the ExitMethod was """ & $sExitMethod & """" & _
			@CR & @CR & " =)", 60)
EndFunc   ;==>__OnAutoItExit

Local $a[1]
$a[1] = "" ; the error

Func FatalErrormessageFromExitCode($iExitCode)
	; https://www.autoitscript.com/autoit3/docs/appendix/Exitcodes.htm
	Local $sExitCode = 'uncatalogued event'
	Switch $iExitCode
		Case 0x7FFFF068
			$sExitCode = 'Unable to open the script file.'
		Case 0x7FFFF069
			$sExitCode = 'Badly formatted "Func" statement.'
		Case 0x7FFFF06A
			$sExitCode = 'Unable to parse line.'
		Case 0x7FFFF06B
			$sExitCode = 'Missing right bracket '')'' in expression.'
		Case 0x7FFFF06C
			$sExitCode = 'Missing operator in expression.'
		Case 0x7FFFF06D
			$sExitCode = 'Unbalanced brackets in expression.'
		Case 0x7FFFF06E
			$sExitCode = 'Error in expression.'
		Case 0x7FFFF06F
			$sExitCode = 'Error parsing function call.'
		Case 0x7FFFF070
			$sExitCode = 'Incorrect number of parameters in function call.'
		Case 0x7FFFF071
			$sExitCode = '"ReDim" used without an array variable.'
		Case 0x7FFFF072
			$sExitCode = 'Illegal text at the end of statement (one statement per line).'
		Case 0x7FFFF073
			$sExitCode = '"If" statement has no matching "EndIf" statement.'
		Case 0x7FFFF074
			$sExitCode = '"Else" statement with no matching "If" statement.'
		Case 0x7FFFF075
			$sExitCode = '"EndIf" statement with no matching "If" statement.'
		Case 0x7FFFF076
			$sExitCode = 'Too many "Else" statements for matching "If" statement.'
		Case 0x7FFFF077
			$sExitCode = '"While" statement has no matching "WEnd" statement.'
		Case 0x7FFFF078
			$sExitCode = '"WEnd" statement with no matching "While" statement.'
		Case 0x7FFFF079
			$sExitCode = 'Variable used without being declared.'
		Case 0x7FFFF07A
			$sExitCode = 'Array variable has incorrect number of subscripts or subscript dimension range exceeded.'
		Case 0x7FFFF07B
			$sExitCode = 'Array variable subscript badly formatted.'
		Case 0x7FFFF07C
			$sExitCode = 'Subscript used with non-Array variable.'
		Case 0x7FFFF07D
			$sExitCode = 'Too many subscripts used for an array.'
		Case 0x7FFFF07E
			$sExitCode = 'Missing subscript dimensions in "Dim" statement.'
		Case 0x7FFFF07F
			$sExitCode = 'No variable given for "Dim", "Local", "Global" or "Const" statement.'
		Case 0x7FFFF080
			$sExitCode = 'Expected a "=" operator in assignment statement.'
		Case 0x7FFFF081
			$sExitCode = 'Invalid keyword at the start of this line.'
		Case 0x7FFFF082
			$sExitCode = 'Array maximum size exceeded.'
		Case 0x7FFFF083
			$sExitCode = '"Func" statement has no matching "EndFunc".'
		Case 0x7FFFF084
			$sExitCode = 'Duplicate function name.'
		Case 0x7FFFF085
			$sExitCode = 'Unknown function name.'
		Case 0x7FFFF086
			$sExitCode = 'Unknown macro.'
		Case 0x7FFFF087
			$sExitCode = 'Unable to execute the external program.'
		Case 0x7FFFF08B
			$sExitCode = 'Unknown option or bad parameter specified.'
		Case 0x7FFFF08C
			$sExitCode = 'Unable to load the internet libraries.'
		Case 0x7FFFF08E
			$sExitCode = 'Unable to open file, the maximum number of open files has been exceeded.'
		Case 0x7FFFF08F
			$sExitCode = 'Invalid file handle used.'
		Case 0x7FFFF090
			$sExitCode = 'Invalid file filter given.'
		Case 0x7FFFF091
			$sExitCode = 'Expected a variable in user function call.'
		Case 0x7FFFF092
			$sExitCode = '"Do" statement has no matching "Until" statement.'
		Case 0x7FFFF093
			$sExitCode = '"Until" statement with no matching "Do" statement.'
		Case 0x7FFFF094
			$sExitCode = '"For" statement is badly formatted.'
		Case 0x7FFFF095
			$sExitCode = '"Next" statement with no matching "For" statement.'
		Case 0x7FFFF096
			$sExitCode = '"ExitLoop/ContinueLoop" statements only valid from inside a For/Do/While loop.'
		Case 0x7FFFF097
			$sExitCode = '"For" statement has no matching "Next" statement.'
		Case 0x7FFFF098
			$sExitCode = '"Case" statement with no matching "Select"or "Switch" statement.'
		Case 0x7FFFF099
			$sExitCode = '"EndSelect" statement with no matching "Select" statement.'
		Case 0x7FFFF09A
			$sExitCode = 'Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.'
		Case 0x7FFFF09B
			$sExitCode = 'Unable to access RunAs API.'
		Case 0x7FFFF09C
			$sExitCode = 'String missing closing quote.'
		Case 0x7FFFF09E
			$sExitCode = 'Badly formated variable or macro.'
		Case 0x7FFFF09F
			$sExitCode = 'This keyword cannot be used after a "Then" keyword.'
		Case 0x7FFFF0A0
			$sExitCode = '"Select" statement is missing "EndSelect" or "Case" statement.'
		Case 0x7FFFF0A1
			$sExitCode = '"If" statements must have a "Then" keyword.'
		Case 0x7FFFF0A3
			$sExitCode = 'Cannot assign values to constants.'
		Case 0x7FFFF0A4
			$sExitCode = 'Cannot make existing variables into constants.'
		Case 0x7FFFF0A7
			$sExitCode = 'Object referenced outside a "With" statement.'
		Case 0x7FFFF0A8
			$sExitCode = 'Nested "With" statements are not allowed.'
		Case 0x7FFFF0A9
			$sExitCode = 'Variable must be of type "Object".'
		Case 0x7FFFF0AA
			$sExitCode = 'The requested action with this object has failed.'
		Case 0x7FFFF0AB
			$sExitCode = 'Variable appears more than once in function declaration.'
		Case 0x7FFFF0AC
			$sExitCode = 'ReDim array can not be initialized in this manner.'
		Case 0x7FFFF0AD
			$sExitCode = 'An array variable can not be used in this manner.'
		Case 0x7FFFF0AE
			$sExitCode = 'Can not redeclare a constant.'
		Case 0x7FFFF0AF
			$sExitCode = 'Can not redeclare a parameter inside a user function.'
		Case 0x7FFFF0B0
			$sExitCode = 'Can pass constants by reference only to parameters with "Const" keyword.'
		Case 0x7FFFF0B1
			$sExitCode = 'Can not initialize a variable with itself.'
		Case 0x7FFFF0B2
			$sExitCode = 'Incorrect way to use this parameter.'
		Case 0x7FFFF0B3
			$sExitCode = '"EndSwitch" statement with no matching "Switch" statement.'
		Case 0x7FFFF0B4
			$sExitCode = '"Switch" statement is missing "EndSwitch" or "Case" statement.'
		Case 0x7FFFF0B5
			$sExitCode = '"ContinueCase" statement with no matching "Select"or "Switch" statement.'
		Case 0x7FFFF0B6
			$sExitCode = 'Assert Failed!'
		Case 0x7FFFF0B7
			$sExitCode = 'AutoIt has encountered a fatal crash as a result of:\r Unable to execute DllCall.'
		Case 0x7FFFF0B8
			$sExitCode = 'Obsolete function/parameter.'
		Case 0x7FFFF0B9
			$sExitCode = 'Invalid Exitcode (reserved for AutoIt internal use).'
	EndSwitch
	Return SetError(0, $iExitCode, $sExitCode)
EndFunc   ;==>FatalErrormessageFromExitCode

You are really attentive. Thanks Jpm.

comment:12 Changed 4 years ago by argumentum

...and now that I think of it, the @ScriptLineNumber is not part of the information available on the OnAutoItExitRegister() function. =(

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.