Sign in to follow this  
Followers 0
Undutchable

@extended (error handling)

5 posts in this topic

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.

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

Damn!

Well.. better get started.. :)

Thanks Szhlopp

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Awesome! It's perfect.

Thanks PsaltyDS! :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0