-
Notifications
You must be signed in to change notification settings - Fork 1
/
SCError.cpp
48 lines (46 loc) · 1.53 KB
/
SCError.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*!
\file SCError.cpp
\copyright (c) Kaido Kert ( [email protected] )
\licence BSD
\author $Author: kaidokert $
\date $Date: 2009-07-06 13:21:43 +0300 (Mon, 06 Jul 2009) $
*/
// Revision $Revision: 345 $
#include "SCError.h"
#include "common.h"
SCError::SCError(long err) : runtime_error("smart card API error"),error(err)
{
std::ostringstream buf;
switch(err & 0xFFFFFFFF) {
case 0x80100017 : //SCARD_E_READER_UNAVAILABLE
buf << "No smart card readers"; break;
case 0x80100069 : //SCARD_W_REMOVED_CARD
buf << "No card in specified reader"; break;
case 0x80100011 : //SCARD_E_INVALID_VALUE .. needs trapping
buf << "Another application is using the card"; break;
case 0x8010000b : //SCARD_E_SHARING_VIOLATION
buf << "The smart card cannot be accessed because of other connections outstanding"; break;
case 0x8010000f : //SCARD_E_PROTO_MISMATCH
buf << "The requested protocols are incompatible with the protocol currently in use with the smart card"; break;
case 0x8010001D : // SCARD_E_NO_SERVICE
buf << "Smart card manager (PC/SC service) is not running"; break;
case 0x80100066 : // SCARD_W_UNRESPONSIVE_CARD
buf << "The card is not responding to reset"; break;
default:
buf << "exception:'" << runtime_error::what() <<
"' code:'0x" <<std::hex << std::setfill('0') <<
std::setw(8) << error << "'";
}
desc = buf.str();
}
void SCError::checkError(long err)
{
switch( err )
{
//these are not errors
case 0x80100068: //SCARD_W_RESET_CARD
return;
}
if (err)
throw SCError(err);
}