ComSquare
InvalidAddress.hpp
Go to the documentation of this file.
1 //
2 // Created by anonymus-raccoon on 1/27/20.
3 //
4 
5 #pragma once
6 
7 #include "DebuggableError.hpp"
8 #include "Models/Ints.hpp"
9 #include <exception>
10 #include <ios>
11 #include <sstream>
12 #include <string>
13 
14 namespace ComSquare
15 {
18  {
19  private:
20  std::string _msg;
21 
22  public:
23  InvalidAddress(std::string where, uint24_t addr)
24  {
25  std::stringstream stream;
26  stream << "Could not read/write data at address: " << addr << " from " << where;
27  this->_msg = stream.str();
28  }
29  const char *what() const noexcept override { return this->_msg.c_str(); }
30  };
31 
33  class InvalidRectangleAddress : public std::exception
34  {
35  private:
36  std::string _msg;
37 
38  public:
39  InvalidRectangleAddress(std::string where, int32_t addr, int16_t subaddr, int16_t start, int16_t end)
40  {
41  std::stringstream stream;
42  stream << "Could not read/write data at address: 0x" << std::hex << addr << " from " << where;
43  if (subaddr < start)
44  stream << " (" << std::hex << subaddr << " < " << start << ")";
45  else
46  stream << " (" << std::hex << subaddr << " > " << end << ")";
47  this->_msg = stream.str();
48  }
49  const char *what() const noexcept override { return this->_msg.c_str(); }
50  };
51 }// namespace ComSquare
Ints.hpp
ComSquare::InvalidAddress::what
const char * what() const noexcept override
Definition: InvalidAddress.hpp:29
ComSquare::InvalidRectangleAddress::InvalidRectangleAddress
InvalidRectangleAddress(std::string where, int32_t addr, int16_t subaddr, int16_t start, int16_t end)
Definition: InvalidAddress.hpp:39
uint24_t
unsigned uint24_t
Definition: Ints.hpp:10
ComSquare::InvalidAddress::_msg
std::string _msg
Definition: InvalidAddress.hpp:20
ComSquare::InvalidRectangleAddress
Exception thrown when trying to read/write to an invalid address in a rectangle memory region.
Definition: InvalidAddress.hpp:33
ComSquare::InvalidRectangleAddress::what
const char * what() const noexcept override
Definition: InvalidAddress.hpp:49
DebuggableError.hpp
ComSquare::DebuggableError
Definition: DebuggableError.hpp:11
ComSquare::InvalidAddress::InvalidAddress
InvalidAddress(std::string where, uint24_t addr)
Definition: InvalidAddress.hpp:23
ComSquare::InvalidAddress
Exception thrown when trying to read/write to an invalid address.
Definition: InvalidAddress.hpp:17
ComSquare::InvalidRectangleAddress::_msg
std::string _msg
Definition: InvalidAddress.hpp:36
ComSquare
Definition: APU.cpp:12