←Select platform

Code Property

Summary
Gets or sets the code that caused this exception.
Syntax
C#
C++/CLI
Java
Python
public RasterExceptionCode Code { get; set; } 
public RasterExceptionCode getCode(); 
public void setCode( 
   RasterExceptionCode rasterExceptionCode 
); 
public: 
property RasterExceptionCode Code { 
   RasterExceptionCode get(); 
   void set (    RasterExceptionCode ); 
} 
Code # get and set (RasterException) 

Property Value

A RasterExceptionCode value that specifies what caused this exception.

Example
C#
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)); 
		} 
	} 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.16
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.