G
Guest
I am attempting to develop a custom class wich handles caught exceptions, much like the ExceptionManager. I am having difficulty in informing the compiler that my custom class will handle the exception appropriately.
For instance:
bool System.Collections.IDictionary.Contains(object key)
{
if(key is string)
return(this.Contains((string) key));
else
throw(new ArgumentException("key must be of type string.", "key"));
}
The above compiles just fine.
bool System.Collections.IDictionary.Contains(object key)
{
if(key is string)
return(this.Contains((string) key));
else
ExceptionHandler.Handle(new ArgumentException("key must be of type string.", "key"));
}
The above will not compile due to the fact that the compiler detect sthe execution path the does not provide a return.
I know I can modify the code to get this to work, but I was wondernig if anyone knows of an interface or something that my ExceptionHandler can use to inform the compiler that it will be stopping execution stream and can therfore compile the above code.
For instance:
bool System.Collections.IDictionary.Contains(object key)
{
if(key is string)
return(this.Contains((string) key));
else
throw(new ArgumentException("key must be of type string.", "key"));
}
The above compiles just fine.
bool System.Collections.IDictionary.Contains(object key)
{
if(key is string)
return(this.Contains((string) key));
else
ExceptionHandler.Handle(new ArgumentException("key must be of type string.", "key"));
}
The above will not compile due to the fact that the compiler detect sthe execution path the does not provide a return.
I know I can modify the code to get this to work, but I was wondernig if anyone knows of an interface or something that my ExceptionHandler can use to inform the compiler that it will be stopping execution stream and can therfore compile the above code.