←Select platform

GetCodeMessage Method

Summary
Gets the error string that corresponds to a specific TwainExceptionCode

Syntax
C#
C++/CLI
Python
public static string GetCodeMessage( 
   TwainExceptionCode code 
) 
public: 
static String^ GetCodeMessage(  
   TwainExceptionCode code 
)  
def GetCodeMessage(self,code): 

Parameters

code
A TwainExceptionCode value to get the string message for.

Return Value

A String that contains the current message for code

Remarks

By default, TwainException has a string message for each TwainExceptionCode. You can get this message by calling this method. Moreever, you can change any string message for any TwainExceptionCode by using the SetCodeMessage method.

Example
C#
using Leadtools; 
using Leadtools.Twain; 
 
 
public void SetCodeMessageExample() 
{ 
   // Get the initial FileFormat message 
   TwainExceptionCode code = TwainExceptionCode.StopScan; 
   string message = TwainException.GetCodeMessage(code); 
   MessageBox.Show(string.Format("Code: {0}, message: {1}", code, message)); 
 
   // make sure that this message is used now 
   try 
   { 
      throw new TwainException(code); 
   } 
   catch (Exception ex) 
   { 
      MessageBox.Show(ex.Message); 
   } 
 
   // change this message to a custom one 
   TwainException.SetCodeMessage(code, "My new message"); 
 
   // make sure that this new message is used now 
   try 
   { 
      throw new TwainException(code); 
   } 
   catch (Exception ex) 
   { 
      MessageBox.Show(ex.Message); 
   } 
} 
Requirements

Target Platforms

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

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