Skip to content

Commit

Permalink
refactor: Remove unused files, export main module, and improve code r…
Browse files Browse the repository at this point in the history
…eadability
mauro-balades committed Jul 23, 2024
1 parent 9c3110f commit e773ab5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/common/error.h
Original file line number Diff line number Diff line change
@@ -39,15 +39,32 @@ class SourceError {
String mMessage{};
Kind mKind{Error};
};

/// @brief Construct a new source error.
/// @param data The source error data.
explicit SourceError(const Vector<SourceErrorData>& data) : mData(data) {}
/// @brief Get the source error data.
/// @return The source error data.
auto GetData() const -> const Vector<SourceErrorData>& { return mData; }
auto GetData() const -> const Vector<SourceErrorData>&;

/// @brief Append a new Info source error.
auto WithInfo(const String& message, const std::optional<SourceLocation>&
location = std::nullopt) -> SourceError&;
/// @brief Append a new Note source error.
auto WithNote(const String& message, const std::optional<SourceLocation>&
location = std::nullopt) -> SourceError&;
/// @brief Append a new Warning source error.
auto WithWarning(const String& message, const std::optional<SourceLocation>&
location = std::nullopt) -> SourceError&;
private:
Vector<SourceErrorData> mData;
};

/// @brief It displays an error message and immediately exits the program.
/// @param error The error to display.
[[noreturn]] auto FatalError(const Error& error) -> void;

// Group: fmt utils
auto format_as(const Error& error) -> String;
auto format_as(const SourceError& error) -> String;

} // namespace snowball

0 comments on commit e773ab5

Please sign in to comment.