Skip to content
Snippets Groups Projects
Commit 9a42b661 authored by Mattias Ajander's avatar Mattias Ajander
Browse files

Added FileError and special case for missing filenames in trace

parent 664ba877
No related branches found
No related tags found
No related merge requests found
...@@ -107,4 +107,18 @@ public: ...@@ -107,4 +107,18 @@ public:
RuntimeError(const String& message) : FunkError(SourceLocation{"", 0, 0}, "Runtime error", message) {} RuntimeError(const String& message) : FunkError(SourceLocation{"", 0, 0}, "Runtime error", message) {}
}; };
/**
* @brief Exception class for file-related errors.
* Thrown when there is an issue with file operations.
*/
class FileError : public std::runtime_error
{
public:
/**
* @brief Constructs a FileError with message.
* @param message Description of the error
*/
FileError(const String& message) : std::runtime_error(message) {}
};
} // namespace funk } // namespace funk
...@@ -15,6 +15,8 @@ const SourceLocation& FunkError::get_location() const ...@@ -15,6 +15,8 @@ const SourceLocation& FunkError::get_location() const
String FunkError::trace() const String FunkError::trace() const
{ {
if (location.filename.empty()) { return what(); }
std::ostringstream os; std::ostringstream os;
os << type << " in file " << location.filename << " at line " << location.line << ", column " << location.column os << type << " in file " << location.filename << " at line " << location.line << ", column " << location.column
<< '\n'; << '\n';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment