myshell 2.0.0
Loading...
Searching...
No Matches
msh_exception.h
1//
2// Created by andrew on 11/9/23.
3//
4
5#ifndef MYSHELL_MSH_EXCEPTION_H
6#define MYSHELL_MSH_EXCEPTION_H
7
8#include "internal/msh_error.h"
9
10#include <exception>
11#include <string>
12
18class msh_exception : public std::exception {
19public:
20 explicit msh_exception(std::string message, msh_err err = UNKNOWN_ERROR) :
21 message(std::move(message)), err(err) {}
22
23 [[nodiscard]] const char *what() const noexcept override {
24 return message.c_str();
25 }
26
27 [[nodiscard]] msh_err code() const noexcept {
28 return err;
29 }
30
31private:
32 std::string message;
33 msh_err err;
34};
35
36#endif //MYSHELL_MSH_EXCEPTION_H
Internal exception class.
Definition msh_exception.h:18