LEADTOOLS OCR (Leadtools.Forms.Ocr assembly)

GetErrorCodeString Method

Show in webframe
Example 







engine-specific error code value. This is normally obtained as the Code member when an exception of type OcrException is thrown by this IOcrEngine.
Gets a string description of an engine-specific error code value.
Syntax
string GetErrorCodeString( 
   long code
)
'Declaration
 
Function GetErrorCodeString( _
   ByVal code As Long _
) As String
'Usage
 
Dim instance As IOcrEngine
Dim code As Long
Dim value As String
 
value = instance.GetErrorCodeString(code)
string GetErrorCodeString( 
   long code
)
- (NSString*)getErrorCodeString:(long long) code;
public String getErrorCodeString(long code)
function Leadtools.Forms.Ocr.IOcrEngine.GetErrorCodeString( 
   code 
)
String^ GetErrorCodeString( 
   int64 code
) 

Parameters

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 System.String that contains a short description of the error code value.
Remarks

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, System.ArgumentException and System.InvalidOperationException respectively Errors caused by loading invalid image files using RasterCodecsInstance will throw exceptions of type Leadtools.RasterException. Errors for missing features (support locked) will throw OcrSupportLockedException exceptions. Any other runtime error in the engine will throw an OcrException.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms.Ocr
Imports Leadtools.Forms
Imports Leadtools.Forms.DocumentWriters
Imports Leadtools.WinForms

Public Sub GetErrorCodeStringExample()
   ' Create a brand new directory
   Dim engineDir As String = "C:\MyApp\WrongOcrEngineDirectory"
   If (Directory.Exists(engineDir)) Then
      Directory.Delete(engineDir, True)
   End If

   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 ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, False)
      ' Start it up with our wrong engine directory (this should cause an exception)
      Try
         ocrEngine.Startup(Nothing, Nothing, Nothing, engineDir)

      Catch ex As OcrException
         ' Get and show a description of the error
         Dim code As Long = ex.Code
         Dim description As String = ocrEngine.GetErrorCodeString(code)
         Console.WriteLine(description)
      End Try
   End Using
End Sub
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms.Ocr;
using Leadtools.Forms.DocumentWriters;

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.Advantage, false))
   {
      // 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);
      }
   }
}
Requirements

Target Platforms

See Also

Reference

IOcrEngine Interface
IOcrEngine Members
Startup
IsStarted Property
Shutdown Method
IOcrPage Interface
OcrEngineManager Class
OcrEngineType Enumeration
Programming with the LEADTOOLS .NET OCR

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.

GetErrorCodeString requires an OCR module license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features