我正在编写捕获此代码的代码OutOfMemoryException并抛出一个新的,更直观的异常:
/// ...
/// <exception cref="FormatException">The file does not have a valid image format.</exception>
public static Image OpenImage( string filename )
{
try
{
return Image.FromFile( filename );
}
catch( OutOfMemoryException ex )
{
throw new FormatException( "The file does not have a valid image format.", ex );
}
}
此代码是否为其用户所接受,或者是OutOfMemoryException出于特殊原因故意被抛出?
偶然的你
一只斗牛犬
相关分类