diff --git a/src/raven.js b/src/raven.js
index <HASH>..<HASH> 100644
--- a/src/raven.js
+++ b/src/raven.js
@@ -338,7 +338,11 @@ function parseDSN(str) {
         dsn = {},
         i = 7;
 
-    while (i--) dsn[dsnKeys[i]] = m[i] || '';
+    try {
+        while (i--) dsn[dsnKeys[i]] = m[i] || '';
+    } catch(e) {
+        throw new RavenConfigError('Invalid DSN');
+    }
 
     if (dsn.pass)
         throw new RavenConfigError('Do not specify your private key in the DSN.');
diff --git a/test/raven.test.js b/test/raven.test.js
index <HASH>..<HASH> 100644
--- a/test/raven.test.js
+++ b/test/raven.test.js
@@ -174,6 +174,16 @@ describe('globals', function() {
             // shouldn't hit this
             assert.isTrue(false);
         });
+
+        it('should raise a RavenConfigError with an invalid DSN', function() {
+          try {
+            parseDSN('lol');
+          } catch(e) {
+            return assert.equal(e.name, 'RavenConfigError');
+          }
+          // shouldn't hit this
+          assert.isTrue(false);
+        });
     });
 
     describe('normalizeFrame', function() {
Raise a RavenConfigError with an invalid DSN in general