I have defined a user Exception class. The exception will be thrown in
GetNextToken() reads a file stream, pulling characters until a predefined delimiters are met (space, end of line, etc) returning the string. I can not change anything in GetNextToken.
If GetNextToken does not return an int value I would like to throw my user defined exception. I have been unable to do so. As soon as as Int32.Parse() finds the input string is not an int it throws an exception.
Is there a way I can throw my user defined exception or use the data field in the predefined exception to add information.
Thanks
Code:
public int GetNextInt()
{
return Int32.Parse(GetNextToken());
}
If GetNextToken does not return an int value I would like to throw my user defined exception. I have been unable to do so. As soon as as Int32.Parse() finds the input string is not an int it throws an exception.
Is there a way I can throw my user defined exception or use the data field in the predefined exception to add information.
Thanks
Comment