DigDeep

@error cases in _CabExtract

6 posts in this topic

#1 ·  Posted (edited)

Hi @ivan

Your _CabExtract.au3 is great to work on. However, I am facing some issues setting up the error codes.

It is not always but I found on few cases I am getting only the error as Case 2, even though the Directory, .CAB file, the extracted directory and the extracted files are all present.

I never get any of the other case errors. Have I set the @Error in correctly here?

#include <_CabExtract.au3>

_CabExtract('Test.cab', 'C:\Temp', 'C:\Temp')
Switch @error
    Case 1
        MsgBox(0, 'Error 1', 'Object creation failure.')
        Exit

    Case 2
        MsgBox(0, 'Error 2', 'Directory not found.')
        Exit

    Case 3
        MsgBox(0, 'Error 3', 'File extraction directory not found.')
        Exit

    Case 4
        MsgBox(0, 'Error 4', 'Cab File empty.')
        Exit
EndSwitch

I believe you have set 6 error codes. Could you please specify the 6 cases?

Edited by DigDeep

Share this post


Link to post
Share on other sites



#2 ·  Posted

If you are talking about this UDF then the functions set @error to values of 1 or 2 and @extended to values of 1 to 6.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

thanks @water

Yeah, I checked earlier and observed that the errors were extended 1 to 6 but not sure why do I get error for Case 2 sometimes... even though the path, directory, .cab file and extracted files are all created.

Share this post


Link to post
Share on other sites

#4 ·  Posted

What I understand from the above mentioned UDF: Means that the expand command returned an error.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

So, to check out I deleted the Switch @error and it is going smoothly now.

It looks like the Case 2 was giving a false alarm even though the files and directories were existing. Who can look at the UDF for checking out the errors?

We would need the error codes if the directory is not getting created, Cab files failed to extract, .CAB file failed to download, etc...

If I am not wrong, below are the 6 cases expanded...

Switch @error
    Case 1
        MsgBox(0, 'Error 1', 'Object creation failure while extracting files.') ;  If Not IsString($pCabPath) Then
        ; Exit

    Case 2
        MsgBox(0, 'Error 2', 'Error while creating directory for extracting files.') ; If Not FileExists($pCabPath) Or Not StringInStr(FileGetAttrib($pCabPath), 'D') Then
        ; Exit

    Case 3
        MsgBox(0, 'Error 3', 'Filename is not Valid.') ; If Not (_IsValidFileName($pCabFile) Or FileExists($pCabPath & '\' & $pCabFile)) Then
        ; Exit

    Case 4
        MsgBox(0, 'Error 4', 'No files were found in CAB or Directory does not exist.') ; If Not FileExists($pDest) Or Not StringInStr(FileGetAttrib($pDest), 'D') Then
        ; Exit

    Case 5
    ; I am not able to understand what is "$pMode" here ; If Not IsNumber($pMode) Or ($pMode < -1 And $pMode > 0) Then
    ; Exit

    Case 6
    MsgBox(0, 'Error 6', 'No files were found in CAB.') ; If @error Or Not IsArray($lFileList) Then
    ; Exit
EndSwitch

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

Again: You are mixing @error and @extended.
As I understand the code (only had a quick glance) this should be:

$sTitle = "Error " & @error & ", Extended " & @extended
Switch @error
    Case 1
        Switch @extended
            Case 1
                MsgBox(0, $sTitle, 'Object creation failure while extracting files.')
            Case 2
                MsgBox(0, $sTitle, 'Error while creating directory for extracting files.')
            Case 3
                MsgBox(0, $sTitle, 'Filename is not Valid.')
            Case 4
                MsgBox(0, $sTitle, 'No files were found in CAB or Directory does not exist.')
            Case 5
                ; I am not able to understand what is "$pMode" here ; If Not IsNumber($pMode) Or ($pMode < -1 And $pMode > 0) Then
                ; Exit
            Case 6
                MsgBox(0, $sTitle, 'No files were found in CAB.')
            Case Else
                MsgBox(0, $sTitle, 'Unknown value for @extended.')
        EndSwitch
    Case 2
        Switch @extended
            Case 1
                MsgBox(0, $sTitle, '...')
            Case 2
                MsgBox(0, $sTitle, '...')
            Case Else
                MsgBox(0, $sTitle, 'Unknown value for @extended.')
        EndSwitch
    Case Else
        MsgBox(0, $sTitle, 'Unknown value for @error.')
EndSwitch

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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