Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Leaders
Posted

       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

  • Administrators
Posted

to steal somebody else's 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 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

 

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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...