[SerializableAttribute()]
public class RasterException : LeadtoolsException
public class RasterException
extends LeadtoolsException
[SerializableAttribute()]
public ref class RasterException : public LeadtoolsException, System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable
class RasterException(LeadtoolsException):
The RasterException class defines a Code property that can be examined to determine what caused the error.
Default messages are implemented for each Code. Get the message by calling the GetCodeMessage method.
using Leadtools;
using Leadtools.Codecs;
public void RasterExceptionExample()
{
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
// Prompt the user for an image
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "All Files|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
// Try to load this image
try
{
RasterImage img = codecs.Load(dlg.FileName);
Console.WriteLine(string.Format("Image in file {0} is loaded", dlg.FileName));
img.Dispose();
}
catch (RasterException ex)
{
// See if LEADTOOLS could not recognize this image format
if (ex.Code == RasterExceptionCode.FileFormat)
Console.WriteLine(string.Format("File {0} does not contain an image format recognizable by LEADTOOLS", dlg.FileName));
else
{
// Other LEADTOOLS error (file might be corrupted, read error, etc)
Console.WriteLine(string.Format("Could not load the file {0}.{1}Leadtools code: {2}{1}Message: {3}", dlg.FileName, Environment.NewLine, ex.Code, ex.Message));
}
}
catch (Exception ex)
{
// Other errors
Console.WriteLine(string.Format("Could not load the file {0}.{1}{2}", dlg.FileName, Environment.NewLine, ex.Message));
}
}
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document