Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a factory for creating MailChimp specific errors

  • Loading branch information...
commit b5c9857e3eb0e941871b10a56ce90395fe61ee7f 1 parent 3b4a642
Daniel Leinich authored August 09, 2012

Showing 1 changed file with 23 additions and 1 deletion. Show diff stats Hide diff stats

  1. 24  lib/mailchimp/helpers.js
24  lib/mailchimp/helpers.js
... ...
@@ -1,4 +1,4 @@
1  
-/***
  1
+/**
2 2
  * Recursively encode an object as application/x-www-form-urlencoded.
3 3
  *
4 4
  * @param value Value to encode
@@ -31,4 +31,26 @@ var serialize = module.exports.serialize = function (value, key) {
31 31
         return key + '=' + encodeURIComponent(value);
32 32
     }
33 33
     
  34
+}
  35
+
  36
+/**
  37
+ * Creates an Error with information received from MailChimp. In addition to an
  38
+ * error message it also includes an error code. A detailed list of known error
  39
+ * messages and codes can be found at the url below for version 1.3 of the API.
  40
+ * 
  41
+ * @see http://apidocs.mailchimp.com/api/1.3/exceptions.field.php
  42
+ * 
  43
+ * @param message The error message
  44
+ * @param code The error code
  45
+ * @return Instance of {@link Error}
  46
+ */
  47
+var createMailChimpError = module.exports.createMailChimpError = function (message, code) {
  48
+
  49
+	error = new Error(message || (message = ''));
  50
+	
  51
+	if (code)
  52
+		error.code = code;
  53
+	
  54
+	return error;
  55
+	
34 56
 }

0 notes on commit b5c9857

Please sign in to comment.
Something went wrong with that request. Please try again.