Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
AIPExceptions.h
1#pragma once
2
3#include <stdexcept>
4#include "Logger.h"
5
6#define AIP_CONNECTION_INCOMPATIBLE 7710
7#define AIP_PIN_ATTRIBUTE_ERROR 7711
8#define AIP_MODULE_INIT_ERROR 7712
9#define AIP_ROI_OUTOFRANGE 7713
10#define AIP_IMAGE_LOAD_FAILED 7714
11#define AIP_PARAM_OUTOFRANGE 7715
12#define AIP_UNIQUE_CONSTRAINT_FAILED 7716
13#define AIP_PINS_VALIDATION_FAILED 7717
14#define AIP_PIN_NOTFOUND 7718
15#define AIP_NOTFOUND 7719
16#define AIP_OUTOFORDER 7720
17#define AIP_LENGTH_MISMATCH 7721
18#define AIP_WRONG_STRUCTURE 7722
19#define AIP_NOTIMPLEMENTED 7723
20#define AIP_NOTSET 7725
21#define AIP_NOTEXEPCTED 7726
22#define MP4_OCOF_END 7726
23
24// Fatal errors
25#define AIP_FATAL 7811
26#define MP4_NAME_PARSE_FAILED 7812
27#define MP4_FILE_CLOSE_FAILED 7813
28#define MP4_RELOAD_RESUME_FAILED 7814
29#define MP4_OPEN_FILE_FAILED 7815
30#define MP4_MISSING_VIDEOTRACK 7816
31#define MP4_MISSING_START_TS 7817
32#define MP4_TIME_RANGE_FETCH_FAILED 7818
33#define MP4_SET_POINTER_END_FAILED 7819
34#define MP4_SEEK_INSIDE_FILE_FAILED 7820
35#define MP4_BUFFER_TOO_SMALL 7821
36#define MP4_OCOF_EMPTY 7721
37#define MP4_OCOF_MISSING_FILE 7822
38#define MP4_OCOF_INVALID_DUR 7823
39#define MP4_UNEXPECTED_STATE 7824
40#define MODULE_ENROLLMENT_FAILED 7825
41#define CTRL_MODULE_INVALID_STATE 7826
42
43
44#define AIPException_LOG_SEV(severity,type) for(std::ostringstream stream; Logger::getLogger()->push(severity, stream);) Logger::getLogger()->aipexceptionPre(stream, severity,type)
45
46// class referred from https://stackoverflow.com/a/8152888
47
48class AIP_Exception : public std::runtime_error
49{
50public:
54 explicit AIP_Exception(int type,const std::string file,int line,const std::string logMessage) :
55 runtime_error(std::to_string(type))
56 {
57 if (type > AIP_FATAL)
58 {
59 AIPException_LOG_SEV(boost::log::trivial::severity_level::fatal,type) << file << ":" << line << ":" << logMessage.c_str();
60 }
61 else
62 {
63 AIPException_LOG_SEV(boost::log::trivial::severity_level::error,type) << file << ":" << line << ":" << logMessage.c_str();
64 }
65 message = logMessage;
66 }
67 explicit AIP_Exception(int type,const std::string file,int line,const std::string logMessage, std::string _previosFile, std::string _nextFile) :
68 runtime_error(std::to_string(type))
69 {
70 previousFile = _previosFile;
71 nextFile = _nextFile;
72 AIPException_LOG_SEV(boost::log::trivial::severity_level::error,type) << file << ":" << line << ":" << previousFile.c_str() << ":" << nextFile.c_str() << ":" << logMessage.c_str();
73 }
77 virtual ~AIP_Exception() throw () {}
78 int getCode()
79 {
80 return atoi(what());
81 }
82 std::string getError()
83 {
84 return message;
85 }
86 std::string getPreviousFile()
87 {
88 return previousFile;
89 }
90 std::string getNextFile()
91 {
92 return nextFile;
93 }
94private:
95 std::string message;
96 std::string previousFile;
97 std::string nextFile;
98};
100{
101public:
102 explicit Mp4_Exception(int type, const std::string file, int line, const std::string logMessage) :
103 AIP_Exception(type, file, line, logMessage)
104 {
105 }
106 explicit Mp4_Exception(int type, const std::string file, int line, int _openFileErrorCode, const std::string logMessage) :
107 AIP_Exception(type, file, line, logMessage)
108 {
109 openFileErrorCode = _openFileErrorCode;
110 }
111 explicit Mp4_Exception(int type, const std::string file, int line, const std::string logMessage, std::string previosFile, std::string nextFile) :
112 AIP_Exception(type, file, line, logMessage, previosFile, nextFile)
113 {
114 }
116 {
117 return openFileErrorCode;
118 }
119private:
121};
122#define AIPException(_type,_message) AIP_Exception(_type,__FILE__,__LINE__,_message)
123#define Mp4Exception(_type,_message) Mp4_Exception(_type,__FILE__,__LINE__,_message)
124#define Mp4ExceptionNoVideoTrack(_type,_message, _previosFile, _nextFile) Mp4_Exception(_type,__FILE__,__LINE__,_message,_previosFile,_nextFile)
Definition AIPExceptions.h:49
std::string previousFile
Definition AIPExceptions.h:96
AIP_Exception(int type, const std::string file, int line, const std::string logMessage)
Definition AIPExceptions.h:54
std::string message
Definition AIPExceptions.h:95
AIP_Exception(int type, const std::string file, int line, const std::string logMessage, std::string _previosFile, std::string _nextFile)
Definition AIPExceptions.h:67
std::string nextFile
Definition AIPExceptions.h:97
std::string getPreviousFile()
Definition AIPExceptions.h:86
virtual ~AIP_Exception()
Definition AIPExceptions.h:77
int getCode()
Definition AIPExceptions.h:78
std::string getError()
Definition AIPExceptions.h:82
std::string getNextFile()
Definition AIPExceptions.h:90
Definition AIPExceptions.h:100
Mp4_Exception(int type, const std::string file, int line, const std::string logMessage, std::string previosFile, std::string nextFile)
Definition AIPExceptions.h:111
Mp4_Exception(int type, const std::string file, int line, const std::string logMessage)
Definition AIPExceptions.h:102
int openFileErrorCode
Definition AIPExceptions.h:120
Mp4_Exception(int type, const std::string file, int line, int _openFileErrorCode, const std::string logMessage)
Definition AIPExceptions.h:106
int getOpenFileErrorCode()
Definition AIPExceptions.h:115