Skip to content

Commit

Permalink
Improve error handling and docs, see #786
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Sep 24, 2019
1 parent 051c1d1 commit 22560b6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions js/common/ChipperStringUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
if ( result.value === undefined ) {
throw new Error( `no value for string: ${key}` );
}
if ( typeof result.value !== 'string' ) {
throw new Error( `value should be a string for key ${key}` );
}
return result.value;
}

Expand All @@ -176,8 +179,7 @@
},

/**
* Call a function on each string object in a string map. Recursively dive into each object that doesn't have a
* `value` to find nested string objects too.
* Call a function on each object with a value attribute in an object tree.
* @param {Object.<string, Object|{value:string}>} map - string map, like a loaded JSON strings file
* @param {function(key:string, {value:string})} func
* @public
Expand Down

0 comments on commit 22560b6

Please sign in to comment.