Project
Loading...
Searching...
No Matches
RawDecodingError.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef ALICEO2_EMCAL_RAWDECODINGERROR_H
12#define ALICEO2_EMCAL_RAWDECODINGERROR_H
13
14#include <array>
15#include <cassert>
16#include <exception>
17
18namespace o2
19{
20
21namespace emcal
22{
23
35class RawDecodingError : public std::exception
36{
37 public:
50
56 RawDecodingError(ErrorType_t errtype, int fecID) : mErrorType(errtype), mFecID(fecID)
57 {
58 }
59
61 ~RawDecodingError() noexcept override = default;
62
65 const char* what() const noexcept override
66 {
67 return getErrorCodeDescription(mErrorType);
68 }
69
72 ErrorType_t getErrorType() const { return mErrorType; }
73
76 int getFECID() const { return mFecID; }
77
81 {
82 switch (errortype) {
84 return 0;
86 return 1;
88 return 2;
90 return 3;
92 return 4;
94 return 5;
96 return 6;
98 return 7;
99 };
100 // can never reach this, due to enum class
101 // just to make Werror happy
102 return -1;
103 }
104
107 static constexpr int getNumberOfErrorTypes() { return 8; }
108
118
126 static const char* getErrorCodeNames(ErrorType_t errortype)
127 {
128 switch (errortype) {
130 return "PageNotFound";
132 return "HeaderDecoding";
134 return "PayloadDecoding";
136 return "HeaderCorruption";
138 return "PageStartInvalid";
140 return "PayloadCorruption";
142 return "TrailerDecoding";
144 return "TrailerIncomplete";
145 };
146 return "Undefined error";
147 }
148
156 static const char* getErrorCodeNames(unsigned int errortype)
157 {
158 return getErrorCodeNames(intToErrorType(errortype));
159 }
160
168 static const char* getErrorCodeTitles(ErrorType_t errortype)
169 {
170 switch (errortype) {
172 return "Page not found";
174 return "Header decoding";
176 return "Payload decoding";
178 return "Header corruption";
180 return "Page start invalid";
182 return "Payload corruption";
184 return "Trailer decoding";
186 return "Trailer incomplete";
187 };
188 return "Undefined error";
189 }
190
198 static const char* getErrorCodeTitles(unsigned int errortype)
199 {
200 return getErrorCodeTitles(intToErrorType(errortype));
201 }
202
210 static const char* getErrorCodeDescription(ErrorType_t errortype)
211 {
212 switch (errortype) {
214 return "Page with requested index not found";
216 return "RDH of page cannot be decoded";
218 return "Payload of page cannot be decoded";
220 return "Access to header not belonging to requested superpage";
222 return "Page decoding starting outside payload size";
224 return "Access to payload not belonging to requested superpage";
226 return "Inconsistent trailer in memory";
228 return "Incomplete trailer";
229 };
230 return "Undefined error";
231 }
232
240 static const char* getErrorCodeDescription(unsigned int errortype)
241 {
242 return getErrorCodeDescription(intToErrorType(errortype));
243 }
244
245 private:
246 ErrorType_t mErrorType;
247 int mFecID;
248};
249
254std::ostream& operator<<(std::ostream& stream, const RawDecodingError& error);
255
260std::ostream& operator<<(std::ostream& stream, const RawDecodingError::ErrorType_t& error);
261
262} // namespace emcal
263
264} // namespace o2
265
266#endif
Error handling of the raw reader.
~RawDecodingError() noexcept override=default
destructor
static const char * getErrorCodeDescription(ErrorType_t errortype)
Get description of error type.
static const char * getErrorCodeNames(unsigned int errortype)
Get name of error type.
const char * what() const noexcept override
Providing error message of the exception.
static constexpr int getNumberOfErrorTypes()
Get the number of error codes.
static const char * getErrorCodeTitles(ErrorType_t errortype)
Get title of error type.
static const char * getErrorCodeNames(ErrorType_t errortype)
Get name of error type.
ErrorType_t
Codes for different error types.
@ TRAILER_INCOMPLETE
Incomplete trailer words (i.e. registers)
@ HEADER_DECODING
Header cannot be decoded (format incorrect)
@ TRAILER_DECODING
Inconsistent trailer in memory (several trailer words missing the trailer marker)
@ PAGE_NOTFOUND
Page was not found (page index outside range)
@ HEADER_INVALID
Header in memory not belonging to requested superpage.
@ PAGE_START_INVALID
Page position starting outside payload size.
@ PAYLOAD_DECODING
Payload cannot be decoded (format incorrect)
@ PAYLOAD_INVALID
Payload in memory not belonging to requested superpage.
static int ErrorTypeToInt(RawDecodingError::ErrorType_t errortype)
Convert error type to error code number.
static ErrorType_t intToErrorType(unsigned int errortype)
RawDecodingError(ErrorType_t errtype, int fecID)
Constructor.
static const char * getErrorCodeTitles(unsigned int errortype)
Get title of error type.
int getFECID() const
Get the ID of the frontend electronics responsible for the error.
ErrorType_t getErrorType() const
Get the type identifier of the error handled with this exception.
static const char * getErrorCodeDescription(unsigned int errortype)
Get description of error type.
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
Definition Cell.cxx:355
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...