Package uk.co.nimp.scard

Source Code of uk.co.nimp.scard.SmartwareException

package uk.co.nimp.scard;

import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import static uk.co.nimp.scard.SmartwareTerminalManager.*;

/**
* Exception for PC/SC errors. The native code portion checks the return value
* of the SCard* functions. If it indicates an error, the native code constructs
* an instance of this exception, throws it, and returns to Java.
*
*/
final class SmartwareException extends ScardException {
    static final long serialVersionUID = -3112395494079019804L;
   
    SmartwareException(int code) {
  super(toErrorString(code));
  this.code = code;
    }

    SmartwareException(String msg, int code) {
  super(msg+"\n"+toErrorString(code));
  this.code = code;
    }
   
    private static String toErrorString(int code) {
        PointerByReference pMsg=new PointerByReference();
        Pointer msg;
        String out;
        if(null!=win32MlOsMainDll){
            win32MlOsMainDll.err_Msg(code, pMsg);
            msg=pMsg.getValue();
            out=msg.getString(0);
        }else{
            out="Could not retrieve error description, MLOSMAIN Dll not loaded.\nError code="+code;
        }
        return out;
    }
}
TOP

Related Classes of uk.co.nimp.scard.SmartwareException

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.