Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve nml parsing error messages for missing strings #3227

Merged
merged 3 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
- Renamed "Soma Clicking" to "Single-Node-Tree Mode". [#3141](https://github.com/scalableminds/webknossos/pull/3141/files)
- The fallback segmentation layer attribute of volume tracings is now persisted to NML/ZIP files. Upon re-upload, only volume tracings with this attribute will show a fallback layer. Use `tools/volumeAddFallbackLayer.py` to add this attribute to existing volume tracings. [#3088](https://github.com/scalableminds/webknossos/pull/3088)
- When splitting a tree, the split part that contains the initial node will now keep the original tree name and id. [#3145](https://github.com/scalableminds/webknossos/pull/3145)
- Improve error messages for parsing faulty NMLs. [#3227](https://github.com/scalableminds/webknossos/pull/3227)
- Finished tasks will be displayed with less details and sorted by their finishing date in the dashboard. [#3202](https://github.com/scalableminds/webknossos/pull/3202)
- The welcome header will now also show on the default page if there are no existing organisations. [#3133](https://github.com/scalableminds/webknossos/pull/3133)
- Simplified the sharing of tracings. Users can simply copy the active URL from the browser's URL bar to share a tracing (assuming the tracing is public). [#3176](https://github.com/scalableminds/webknossos/pull/3176)
Expand Down
13 changes: 10 additions & 3 deletions app/assets/javascripts/oxalis/model/helpers/nml_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ function _parseBool(obj: Object, key: string, defaultValue?: boolean): boolean {
return obj[key] === "true";
}

function _parseEntities(obj: Object, key: string): string {
if (obj[key] == null) {
throw new NmlParseError(`${messages["nml.expected_attribute_missing"]} ${key}`);
}
return Saxophone.parseEntities(obj[key]);
}

function findTreeByNodeId(trees: TreeMapType, nodeId: number): ?TreeType {
return _.values(trees).find(tree => tree.nodes.has(nodeId));
}
Expand Down Expand Up @@ -447,7 +454,7 @@ export function parseNml(
_parseFloat(attr, "color.g", DEFAULT_COLOR[1]),
_parseFloat(attr, "color.b", DEFAULT_COLOR[2]),
],
name: Saxophone.parseEntities(attr.name),
name: _parseEntities(attr, "name"),
comments: [],
nodes: new DiffableMap(),
branchPoints: [],
Expand Down Expand Up @@ -519,7 +526,7 @@ export function parseNml(
case "comment": {
const currentComment = {
nodeId: _parseInt(attr, "node"),
content: Saxophone.parseEntities(attr.content),
content: _parseEntities(attr, "content"),
};
const tree = findTreeByNodeId(trees, currentComment.nodeId);
if (tree == null)
Expand All @@ -545,7 +552,7 @@ export function parseNml(
case "group": {
const newGroup = {
groupId: _parseInt(attr, "id"),
name: Saxophone.parseEntities(attr.name),
name: _parseEntities(attr, "name"),
children: [],
};
if (existingGroupIds.has(newGroup.groupId))
Expand Down