System.ArgumentException

nibsy

Regular
Joined
Aug 7, 2002
Messages
51
Location
Kent, UK
I have an application which analyses website usage logs.

The program reads in a file to analyse.

I received the following error message when running the application:

System.ArgumentException: Found a high surrogate char without a following low surrogate at index: 546. This input may not be in this encoding, or may not contain valid unicode (UTF-16) characters.

Inspecting the website logs manually it seems there is some unexpected corrupt data within the file.

I was wondering if there was a way of catching this error to stop the program crashing?

Any help will be gratefully received.
 
Visual Basic:
        Try
            Shell("", AppWinStyle.NormalFocus, True)
            '// your code would go here
            '/// i made this to purposely throw an error
            '/// basically it tries to open something that doesnt exsist
        Catch
            MsgBox("error: " & Err.Description)
        End Try
hope this helps
 
to steal somebody else's code
Visual Basic:
Try
            Shell("", AppWinStyle.NormalFocus, True)
            '// your code would go here
            '/// i made this to purposely throw an error
            '/// basically it tries to open something that doesnt exsist
Catch ex as System.ArgumentException       'Use this here
            MsgBox("error: " & ex.Message)      'Also look at ex.ParamName
        End Try

this also allows you to catch multiple different errors

Visual Basic:
try

'Iffy code here

catch ex as System.ArgumentException
 'handle error here
catch ex as System.InvalidCastException
'handle type mismatch

end try

hope that helps
 
Back
Top