mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-02-07 18:26:49 +08:00
pass details to eval_exceptions for getting an object
This adds the current file, line and column to an exception thrown during object lookup.
Tested with `chai.eval("puts(bogusvar[0])")` and `chai.eval_file(file_containing_the_same)` and it printed the line and filename/`__EVAL__`.
This commit is contained in:
parent
6abbd9dd1b
commit
b1ada418d8
@ -298,7 +298,15 @@ namespace chaiscript
|
|||||||
return t_ss.get_object(this->text, m_loc);
|
return t_ss.get_object(this->text, m_loc);
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception &) {
|
||||||
throw exception::eval_error("Can not find object: " + this->text);
|
File_Position file_position(this->location.start.line, this->location.start.column);
|
||||||
|
std::string what = std::string("Can not find object: ") + this->text;
|
||||||
|
if (this->location.filename != nullptr) {
|
||||||
|
const std::string& filename = *this->location.filename.get();
|
||||||
|
throw exception::eval_error(what, file_position, filename);
|
||||||
|
} else {
|
||||||
|
const std::string& filename = "Unknown";
|
||||||
|
throw exception::eval_error(what, file_position, filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user