MaCh3  2.4.2
Reference Guide
MaCh3Exception.h
Go to the documentation of this file.
1 #pragma once
2 
3 // C++ Includes
4 #include <iostream>
5 #include <string>
6 #include <stdexcept>
7 
8 // MaCh3 Includes
9 #include "Manager/MaCh3Logger.h"
10 #include "Manager/Core.h"
11 
20 
21 
23 class MaCh3Exception : public std::exception {
24 public:
29  explicit MaCh3Exception(std::string File, int Line, std::string Message = "")
30  {
31  size_t lastSlashPos = File.find_last_of('/');
32  std::string fileName = (lastSlashPos != std::string::npos) ? File.substr(lastSlashPos + 1) : File;
33 
34  errorMessage = ((Message.empty()) ? "Terminating MaCh3" : Message);
35  // KS: Set logger format where we only have have "information type", line would be confusing
36  spdlog::set_pattern("[%^%l%$] %v");
37  MACH3LOG_ERROR("Find me here: {}::{}", fileName, Line);
38  }
39 
42  const char* what() const noexcept override {
43  return errorMessage.c_str();
44  }
45 
46 private:
48  std::string errorMessage;
49 };
KS: Core MaCh3 definitions and compile-time configuration utilities.
MaCh3 Logging utilities built on top of SPDLOG.
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:37
Custom exception class used throughout MaCh3.
const char * what() const noexcept override
Returns the error message associated with this exception.
MaCh3Exception(std::string File, int Line, std::string Message="")
Constructs a MaCh3Exception object with the specified error message.
std::string errorMessage
The error message associated with this exception.