←Select platform

LeadtoolsException Class

Summary
Base class for all exception classes thrown by LEADTOOLS.
Syntax
C#
C++/CLI
Java
Python
[SerializableAttribute()] 
public abstract class LeadtoolsException : Exception 
[SerializableAttribute()] 
public ref class LeadtoolsException abstract : public System.Exception, System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable   
public abstract class LeadtoolsException 
    extends java.lang.RuntimeException 
class LeadtoolsException(Exception): 
Remarks

The LeadtoolsException is an abstract class that provides common functionality for all exception classes used in LEADTOOLS such as RasterException.

Example
C#
Java
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)); 
		} 
	} 
} 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
 
 
public void rasterExceptionExample() { 
    final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
    RasterCodecs codecs = new RasterCodecs(); 
    codecs.setThrowExceptionsOnInvalidImages(true); 
 
    // Load an image 
    // Change this path to any image file to see if LEADTOOLS can handle loading it 
    String fileName = combine(LEAD_VARS_IMAGES_DIR, "Master.jpg"); 
    try { 
        RasterImage image = codecs.load(fileName); 
        System.out.printf("Image in file %s is loaded\n", fileName); 
        image.dispose(); 
    } catch (RasterException ex) { 
        // See if LEADTOOLS could not recognize this image format 
        assertTrue(ex.getCode() == RasterExceptionCode.FILE_FORMAT); 
        System.out.printf("File %s does not contain an image format recognizable by LEADTOOLS\n", fileName); 
    } 
 
    System.out.println("File type is supported by LEADTOOLS"); 
} 
Requirements

Target Platforms

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

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