palimpsest v3.0.0
Loading...
Searching...
No Matches
PalimpsestError.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2022 Stéphane Caron
3
4#pragma once
5
6#include <string>
7
10
12class PalimpsestError : public std::runtime_error {
13 public:
20 PalimpsestError(const std::string& file, unsigned line,
21 const std::string& message)
22 : std::runtime_error(message) {
23 std::ostringstream out;
24 out << "[" << file << ":" << line << "] " << message;
25 message_ = out.str();
26 }
27
34 const std::string& extra_message)
35 : std::runtime_error(other.message_ + extra_message),
36 message_(other.message_ + extra_message) {}
37
39 ~PalimpsestError() throw() {}
40
42 const char* what() const throw() { return message_.c_str(); }
43
44 private:
46 std::string message_;
47};
48
49} // namespace palimpsest::exceptions
Error with file and line references to the calling code.
PalimpsestError(const std::string &file, unsigned line, const std::string &message)
Create a new error.
const char * what() const
Error message.
PalimpsestError(const PalimpsestError &other, const std::string &extra_message)
Copy an existing error, adding to the error message.
Exceptions raised by the library.
Definition: KeyError.h:10