From 5bd4f2ccd77b325a52fb09114e057ee89050e4ff Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Tue, 12 Mar 2013 17:24:45 -0400 Subject: [PATCH] blueslip: Throw a custom exception type (imported from commit 4a3612b63bb4481a56901cc3dd6cea9a3d1a1aea) --- zephyr/static/js/blueslip.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zephyr/static/js/blueslip.js b/zephyr/static/js/blueslip.js index 668325045a..acfbabca7e 100644 --- a/zephyr/static/js/blueslip.js +++ b/zephyr/static/js/blueslip.js @@ -44,6 +44,12 @@ function report_error(msg, stack, opts) { }); } +function BlueslipError() { + return Error.apply(this, arguments); +} + +BlueslipError.prototype = Error.prototype; + exports.log = function blueslip_log (msg) { console.log(msg); }; @@ -61,7 +67,7 @@ exports.warn = function blueslip_warn (msg) { exports.error = function blueslip_error (msg) { if (debug_mode) { - throw new Error(msg); + throw new BlueslipError(msg); } else { console.error(msg); report_error(msg, Error().stack); @@ -73,7 +79,7 @@ exports.fatal = function blueslip_fatal (msg) { report_error(msg, Error().stack, {show_ui_msg: true}); } - throw new Error(msg); + throw new BlueslipError(msg); }; return exports;