better (thread) error handling

This commit is contained in:
2021-05-03 18:32:36 +02:00
parent c17d43724a
commit af92d1f870
2 changed files with 23 additions and 10 deletions

9
ml.h
View File

@@ -67,8 +67,10 @@ private:
// An exception thrown by the lisp
class MlError {
class MlError : public std::exception {
public:
MlError() = delete;
// Create an error with the value that caused the error,
// the scope where the error was found, and the message.
MlError(const MlValue &v, MlEnvironment const &env, const char *msg);
@@ -79,7 +81,10 @@ public:
~MlError();
// Get the printable error description.
std::string description();
std::string description() const;
// inherited from std::exception
virtual const char* what() const noexcept;
private:
MlValue *cause;