다음을 통해 공유


예외 클래스(.NET용 POS v1.14 SDK 설명서)

.NET용 Microsoft POS(Point of Service for .NET) 오류 처리는 예외를 사용하여 구현됩니다. .NET 예외 클래스에 대한 4개의 POS는 다음과 같습니다.

표준 UnifiedPOS(Point Of Service) 오류 코드는 ErrorCode 열거형으로 표시됩니다.

PosException

PosExceptionPosControlException, PosManagementExceptionPosLibraryException에 대한 Base 예외 클래스입니다. PosExceptionSystem.Exception에서 파생됩니다.

PosControlException

PosControlException은 .NET 애플리케이션용 POS에 대한 서비스 개체에서 throw하는 표준 예외입니다.

PosManagementException

PosManagementException은 .NET 장치 관리 POS에서 throw됩니다. 애플리케이션 및 서비스 개체는 PosManagementException을 throw해서는 안 됩니다.

PosLibraryException

PosLibraryExceptionPosExplorer에서 throw됩니다. 애플리케이션 및 서비스 개체는 PosLibraryException을 throw해서는 안 됩니다.

오류 코드

다음 표에서는 UnifiedPOS 표준 오류 코드와 .NET용 POS에서 제공하는 ErrorCode 값 간의 매핑을 제공합니다.

POS ErrorCode 멤버 UnifiedPOS 오류 코드 오류 원인
사용 중 E_BUSY 현재 서비스 개체 상태는 이 요청을 허용하지 않습니다.
Claimed E_CLAIMED 다른 서비스 개체 인스턴스가 이미 POS 디바이스를 클레임했습니다.
닫힘 E_CLOSED POS 디바이스가 닫혔습니다.
사용되지 않음 E_DEPRECATED 메서드는 사용되지 않으며 더 이상 제공되지 않습니다.
사용 안 함 E_DISABLED 디바이스를 사용하지 않도록 설정한 동안에는 작업을 수행할 수 없습니다.
Exists E_EXISTS 파일 이름 또는 그 외 지정된 값이 이미 있습니다.
확장 E_EXTENDED 디바이스별 오류 조건이 발생했습니다.
실패 E_FAILURE POS 디바이스는 디바이스가 시스템에 연결되어 있고 활성 상태인 경우에도 요청된 절차를 수행할 수 없습니다.
Illegal E_ILLEGAL POS 애플리케이션이 디바이스에서 잘못된 작업 또는 지원되지 않는 작업을 시도하거나 잘못된 매개 변수 값을 사용했습니다.
NoExist E_NOEXIST 파일 이름 또는 그 외 지정된 값이 없습니다.
NoHardware E_NOHARDWARE POS 디바이스가 시스템에 연결되어 있지 않거나 켜져 있지 않습니다.
NoService E_NOSERVICE 서비스 개체는 일반적으로 설정 또는 구성 오류로 인해 디바이스와 통신할 수 없습니다.
NotClaimed E_NOTCLAIMED POS 애플리케이션은 메서드 또는 속성 집합 작업을 사용하기 전에 클레임해야 하는 전용 디바이스에 액세스하려고 했습니다.
오프라인 E_OFFLINE POS 디바이스가 오프라인 상태입니다.
제한 시간 E_TIMEOUT 서비스 개체가 POS 디바이스의 응답을 기다리는 동안 시간이 초과되었습니다.

다음 코드 예제에서는 MSR이 POS 예외를 처리하고 해당 예외에 포함된 ErrorCodes를 사용하여 해당 예외에 관한 정보를 수집하는 방법을 보여줍니다.

// Create a new instance of the MSR and opens the device.
msr = (Msr)explorer.CreateInstance(msrinfo);
msr.Open();

// Try to enable the device without first claiming it.
// This will throw a PosControlException which, through
// its ErrorCode, will yield information about the exception.
try
{
   msr.DeviceEnabled = true;
}
catch (PosControlException e)
{

   // Examine the ErrorCode to determine the cause of the error.
   if (e.ErrorCode == ErrorCode.NoHardware)
   {
      Console.WriteLine("The POS device is not connected ");
      Console.WriteLine("to the system or is not turned on.");
   }
   if (e.ErrorCode == ErrorCode.Timeout)
   {
      Console.WriteLine("The Service Object timed out
            waiting for a response from the POS device.");
   }

   // The example has not claimed the MSR, which is an
   // exclusive-access device, before trying to enable
   // it. This will throw the PosControlException
   // and trigger the following conditional block.
   // Once triggered, the MSR will be claimed and enabled.
   if (e.ErrorCode == ErrorCode.NotClaimed)
   {
      Console.WriteLine("The POS application attempted to access ");
      Console.WriteLine("an exclusive-use device that must be ");
      Console.WriteLine("claimed before the method or property ");
      Console.WriteLine("set action can be used.")
      msr.Claim(1000);
      msr.DeviceEnabled = true;
   }
}

참고 항목

참조

개념

기타 리소스