37 lines
973 B
C++
37 lines
973 B
C++
#include "fesa/core/status.h"
|
|
|
|
#include <utility>
|
|
|
|
namespace fesa {
|
|
|
|
Status Status::Ok() { return Status{true, std::nullopt, {}}; }
|
|
|
|
Status Status::Failure(std::vector<Diagnostic> diagnostics) {
|
|
SortDiagnostics(diagnostics);
|
|
return Status{false, std::nullopt, std::move(diagnostics)};
|
|
}
|
|
|
|
Status Status::Failure(FailureCategory category,
|
|
std::vector<Diagnostic> diagnostics) {
|
|
SortDiagnostics(diagnostics);
|
|
return Status{false, category, std::move(diagnostics)};
|
|
}
|
|
|
|
bool Status::IsOk() const noexcept { return is_ok_; }
|
|
|
|
std::optional<FailureCategory> Status::Category() const noexcept {
|
|
return category_;
|
|
}
|
|
|
|
const std::vector<Diagnostic>& Status::Diagnostics() const noexcept {
|
|
return diagnostics_;
|
|
}
|
|
|
|
Status::Status(bool is_ok, std::optional<FailureCategory> category,
|
|
std::vector<Diagnostic> diagnostics)
|
|
: is_ok_{is_ok},
|
|
category_{category},
|
|
diagnostics_{std::move(diagnostics)} {}
|
|
|
|
} // namespace fesa
|