Jump to content

@extended (error handling)


 Share

Recommended Posts

Hello,

I have searched the forums and help file but still couldn't find an answer.

How can I have a description for the error code returned by @extended ?

I'm using the function DriveMapAdd() and, when an error occurs, I would like to inform the user the actual problem and not the error code. For example 53 = Bad Network Path.

Of course I can document every one but that is one heck of a task :) Any sugestions ?

Thanks in advance.

Link to comment
Share on other sites

Hello,

I have searched the forums and help file but still couldn't find an answer.

How can I have a description for the error code returned by @extended ?

I'm using the function DriveMapAdd() and, when an error occurs, I would like to inform the user the actual problem and not the error code. For example 53 = Bad Network Path.

Of course I can document every one but that is one heck of a task >_< Any sugestions ?

Thanks in advance.

Only way is to document the messages :)

Just do something like this:

$Ext = @extended
$Error = ""
If $Ext = 1 Then
    $Error = "BLA"
ElseIf $Ext = 2 Then
    $Error = "Different BLA"
EndIf
MsgBox(0, "", $Error)
Link to comment
Share on other sites

Hello,

I have searched the forums and help file but still couldn't find an answer.

How can I have a description for the error code returned by @extended ?

I'm using the function DriveMapAdd() and, when an error occurs, I would like to inform the user the actual problem and not the error code. For example 53 = Bad Network Path.

Of course I can document every one but that is one heck of a task :) Any sugestions ?

Thanks in advance.

Try this, adapted from _WinAPI_GetLastErrorMessage():
#include <WinAPI.au3>

$n = 53; Error code
MsgBox(64, "Test", _WinAPI_GetErrorMessage($n))

Func _WinAPI_GetErrorMessage($iErrorNum)
    Local $tText

    $tText = DllStructCreate("char Text[4096]")
    _WinAPI_FormatMessage($__WINAPCONSTANT_FORMAT_MESSAGE_FROM_SYSTEM, 0, $iErrorNum, 0, DllStructGetPtr($tText), 4096, 0)
    Return DllStructGetData($tText, "Text")
EndFunc  ;==>_WinAPI_GetErrorMessage

>_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...