Provide useful error message on SpecificationError when creating a camera path

This commit is contained in:
Emma Broman
2021-08-17 15:46:50 +02:00
parent 11a901fa2f
commit 39a6220678
2 changed files with 13 additions and 4 deletions

View File

@@ -412,8 +412,8 @@ Path createPathFromDictionary(const ghoul::Dictionary& dictionary, Path::Type ty
const std::optional<float> duration = p.duration;
bool hasStart = p.startState.has_value();
const Waypoint startPoint = hasStart ?
Waypoint(NavigationState(p.startState.value())) :
const Waypoint startPoint = hasStart ?
Waypoint(NavigationState(p.startState.value())) :
waypointFromCamera();
// TODO: also handle curve type here

View File

@@ -47,7 +47,7 @@ namespace {
"Default Path Type",
"The defualt path type chosen when generating a path. See wiki for alternatives."
" The shape of the generated path will be different depending on the path type."
// TODO (2021-08-15, emmbr) right now there is no way to specify a type for a
// TODO (2021-08-15, emmbr) right now there is no way to specify a type for a
// single path instance, only for any created paths
};
@@ -216,7 +216,7 @@ void PathNavigator::updateCamera(double deltaTime) {
}
void PathNavigator::createPath(const ghoul::Dictionary& dictionary) {
// @TODO (2021-08.16, emmbr): Improve how curve types are handled.
// @TODO (2021-08.16, emmbr): Improve how curve types are handled.
// We want the user to be able to choose easily
const int pathType = _defaultPathType;
@@ -232,6 +232,15 @@ void PathNavigator::createPath(const ghoul::Dictionary& dictionary) {
createPathFromDictionary(dictionary, Path::Type(pathType))
);
}
catch (const documentation::SpecificationError& e) {
LERROR("Could not create camera path");
for (const documentation::TestResult::Offense& o : e.result.offenses) {
LERRORC(o.offender, ghoul::to_string(o.reason));
}
for (const documentation::TestResult::Warning& w : e.result.warnings) {
LWARNINGC(w.offender, ghoul::to_string(w.reason));
}
}
catch (const ghoul::RuntimeError& e) {
LERROR(fmt::format("Could not create path. Reason: ", e.message));
return;