public string GetErrorCodeString(
long code
)
public String getErrorCodeString(long code)
String^ GetErrorCodeString(
int64 code
)
def GetErrorCodeString(self,code):
code
engine-specific error code value. This is normally obtained as the Code member when an exception of type OcrException is thrown by this IOcrEngine.
A String that contains a short description of the error code value.
When a runtime error occurs in this IOcrEngine, an exception of type OcrException is thrown with the engine-specific error code set in the Code member. This error code is engine-specific but a short description can be obtained using the GetErrorCodeString method.
Logic errors such as invalid parameters to methods or invalid operations throw standard .NET exceptions (in this case, ArgumentException and InvalidOperationException respectively Errors caused by loading invalid image files using RasterCodecsInstance will throw exceptions of type RasterException. Errors for missing features (support locked) will throw OcrSupportLockedException exceptions. Any other runtime error in the engine will throw an OcrException.
This example will cause an error in the engine and then catch and display the error code message
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Ocr;
using Leadtools.Document.Writer;
public void GetErrorCodeStringExample()
{
// Create a brand new directory
string engineDir = @"C:\MyApp\WrongOcrEngineDirectory";
if (Directory.Exists(engineDir))
Directory.Delete(engineDir, true);
Directory.CreateDirectory(engineDir);
// This directory exists, but it does not contain the OCR runtimes.
// Calling Startup passing this engine parameters should throw an OcrException
// Create an instance of the engine
using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD))
{
// Start it up with our wrong engine directory (this should cause an exception)
try
{
ocrEngine.Startup(null, null, null, engineDir);
}
catch (OcrException ex)
{
// Get and show a description of the error
long code = ex.Code;
string description = ocrEngine.GetErrorCodeString(code);
Console.WriteLine(description);
}
}
}
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.assertTrue;
import leadtools.*;
import leadtools.codecs.*;
import leadtools.document.writer.*;
import leadtools.ocr.*;
public void IOcrEngineGetErrorCodeStringExample() throws IOException {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resouces\\Images";
// Create a brand new directory
String engineDir = combine(LEAD_VARS_IMAGES_DIR, "WrongOcrEngineDirectory");
Path enginePath = Paths.get(engineDir);
Files.createDirectories(enginePath);
// This directory exists, but it does not contain the OCR runtimes.
// Calling Startup passing this engine parameters should throw an OcrException
// Create an instance of the engine
OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD);
// Start it up with our wrong engine directory (this should cause an exception)
boolean errorOccured = false;
try {
ocrEngine.startup(null, null, null, engineDir);
assertTrue(ocrEngine.isStarted());
} catch (OcrException ex) {
// Get and show a description of the error
long code = ex.getCode();
String description = ocrEngine.getErrorCodeString((int) code);
System.out.println("Error: " + description);
errorOccured = true;
}
assertTrue("Expected exception was not caught", errorOccured);
}
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