Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

throw Error, not string #1

Merged
merged 2 commits into from

2 participants

Brandon Mason Thomas Hunter II
Brandon Mason

Throwing an error will include the stack trace. It's the node convention, and libraries like Mocha expect it.

Brandon Mason

Also added some more details so you can see the key that failed.

Thomas Hunter II tlhunter merged commit b4d9f06 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 21, 2012
  1. throw Error, not string

    bitmage authored
Commits on Nov 22, 2012
  1. added more explicit errors

    bitmage authored
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 index.js
6 index.js
View
@@ -86,7 +86,7 @@ var EasyXml = function() {
if (typeof child === 'string' || typeof child === 'number') {
parentXmlNode.set(key.substring(1), child);
} else {
- throw("non_string_attribute");
+ throw new Error(key + "contained non_string_attribute");
}
} else if (child === null) {
// Null data, send an empty tag
@@ -111,7 +111,7 @@ var EasyXml = function() {
// JavaScript date format
el.text = child.toString();
} else {
- throw("unknown_date_format");
+ throw new Error(key + "contained unknown_date_format");
}
} else if (typeof child === 'object' && child.constructor && child.constructor.name && child.constructor.name === 'Array') {
// Array
@@ -140,7 +140,7 @@ var EasyXml = function() {
el = subElement(parentXmlNode, key);
el.text = child.toString();
} else {
- throw("unknown_data_type");
+ throw new Error(key + " contained unknown_data_type: " + typeof child);
}
}
}
Something went wrong with that request. Please try again.