This repository has been archived by the owner on Dec 4, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
SCError.h
73 lines (64 loc) · 1.94 KB
/
SCError.h
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* SMARTCARDPP
*
* This software is released under either the GNU Library General Public
* License (see LICENSE.LGPL) or the BSD License (see LICENSE.BSD).
*
* Note that the only valid version of the LGPL license as far as this
* project is concerned is the original GNU Library General Public License
* Version 2.1, February 1999
*
*/
#ifndef SCERROR_H
#define SCERROR_H
#include "SCardLog.h"
#define ERROR_NO_MEDIA_IN_DRIVE 1112L
/// Exception class for smartcard subsystem errors
/** Smartcard subsystem errors, like reader busy etc. Currently these are only
thrown for PCSCManager, but CTAPI should derive its own from here and throw them
as well */
class SCError : public std::runtime_error
{
private:
SCardLog scardlog;
const SCError operator=(const SCError &);
protected:
std::string desc;
public:
const long error; //SC Api returns longs
SCError(long err);
virtual ~SCError() throw() {};
virtual const char * what() const throw() { return desc.c_str();}
static void check(long err, int cid, int tid);
};
class NoCardInReaderError: public std::runtime_error
{
public:
NoCardInReaderError() : std::runtime_error("No card in specified reader"){}
};
class CardResetError: public std::runtime_error
{
public:
CardResetError() : std::runtime_error("The specified reader is not currently available for use."){}
};
class NoReadersAvailible: public std::runtime_error
{
public:
NoReadersAvailible() : std::runtime_error("Cannot find a smart card reader."){}
};
class PCSCManagerFailure: public std::runtime_error
{
public:
PCSCManagerFailure() : std::runtime_error("PCSCManager failure"){}
};
class UnsupportedCardHashCombination: public std::runtime_error
{
public:
UnsupportedCardHashCombination() : std::runtime_error("Card does not support provided hash type"){}
};
class UnsupportedHashAlgorythm: public std::runtime_error
{
public:
UnsupportedHashAlgorythm() : std::runtime_error("Unsupported hash provided"){}
};
#endif