Skip to content

Commit b9c3928

Browse files
committed
Fixed error messages from Item initialization #173
1 parent 9d78a1f commit b9c3928

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

source/sitemap/widgets/numeric/SitemapNumeric.mc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ class SitemapNumeric extends SitemapWidget {
2626
// Obtain the item part of the element
2727
try {
2828
_numericItem = new NumericItem(
29-
json.getObject( "item", "no item" ),
29+
json.getObject( "item", "Item not found. Check if the name is correct." ),
3030
isSitemapFresh
3131
);
3232
} catch( ex ) {
3333
// The item does not have the type/label, so we add it to any
34-
// exception thrown when creating the item
34+
// exception thrown when creating the item. To be able to
35+
// access the type/label, we need to initialize the base class
36+
SitemapWidget.initialize( json, null, null, isSitemapFresh, taskQueue );
3537
throw new JsonParsingException(
3638
getType() + " '" + getLabel() + "': " + ex.getErrorMessage() );
3739
}

source/sitemap/widgets/switch/SitemapSwitch.mc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,19 @@ class SitemapSwitch extends SitemapWidget {
4242
taskQueue as TaskQueue
4343
) {
4444
// Obtain the item part of the element
45-
_switchItem = new SwitchItem(
46-
json.getObject( "item", "Switch '" + getLabel() + "' has no item" ),
47-
isSitemapFresh
48-
);
45+
try {
46+
_switchItem = new SwitchItem(
47+
json.getObject( "item", "Item not found. Check if the name is correct." ),
48+
isSitemapFresh
49+
);
50+
} catch( ex ) {
51+
// The item does not have the type/label, so we add it to any
52+
// exception thrown when creating the item. To be able to
53+
// access the type/label, we need to initialize the base class
54+
SitemapWidget.initialize( json, null, null, isSitemapFresh, taskQueue );
55+
throw new JsonParsingException(
56+
getType() + " '" + getLabel() + "': " + ex.getErrorMessage() );
57+
}
4958

5059
// The superclass relies on the item for parsing the icon,
5160
// therefore we initialize it after the item was created

0 commit comments

Comments
 (0)