MaCh3  2.2.3
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 
13 class MaCh3Exception : public std::exception {
14 public:
19  explicit MaCh3Exception(std::string File, int Line, std::string Message = "")
20  {
21  size_t lastSlashPos = File.find_last_of('/');
22  std::string fileName = (lastSlashPos != std::string::npos) ? File.substr(lastSlashPos + 1) : File;
23 
24  errorMessage = ((Message.empty()) ? "Terminating MaCh3" : Message);
25  // KS: Set logger format where we only have have "information type", line would be confusing
26  spdlog::set_pattern("[%^%l%$] %v");
27  MACH3LOG_ERROR("Find me here: {}::{}", fileName, Line);
28  }
29 
32  const char* what() const noexcept override {
33  return errorMessage.c_str();
34  }
35 
36 private:
38  std::string errorMessage;
39 };
KS: Based on this https://github.com/gabime/spdlog/blob/a2b4262090fd3f005c2315dcb5be2f0f1774a005/incl...
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:27
Custom exception class for MaCh3 errors.
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.