System.ArgumentException

nibsy

Well-known member
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.
 
Code:
        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 elses code
[VB]
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
[/VB]

this also allows you to catch multiple different errors

[VB]
try

Iffy code here

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

end try
[/VB]

hope that helps
 

Similar threads

C
Replies
2
Views
143
Coffeecoco930
C
D
Replies
2
Views
174
eyildiz
E
L
Replies
3
Views
84
Colon Terminus
C
Back
Top