←Select platform

GetErrorCodeString Method

Gets a string description of an engine-specific error code value.
public string GetErrorCodeString( 
   long code 
public String getErrorCodeString(long code) 
String^ GetErrorCodeString(  
   int64 code 
def GetErrorCodeString(self,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.

Return Value

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); 
   // 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) 
         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); 

Target Platforms

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

Leadtools.Ocr Assembly

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