Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/catch-error-name.
Anders Kaseorgf92224c744d7
diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.jsindex 499752bcb1c..8768baf23dd 100644--- a/frontend_tests/node_tests/hotkey.js+++ b/frontend_tests/node_tests/hotkey.js@@ -174,13 +174,13 @@ run_test("basic_chars", () => {};try {return hotkey.process_keypress(e);- } catch (err) {+ } catch (error) {// An exception will be thrown here if a different// function is called than the one declared. Try to// provide a useful error message.// add a newline to separate from other console output.console.log('\nERROR: Mapping for character "' + e.which + '" does not match tests.');- throw err;+ throw error;}}@@ -384,13 +384,13 @@ run_test("motion_keys", () => {try {return hotkey.process_keydown(e);- } catch (err) {+ } catch (error) {// An exception will be thrown here if a different// function is called than the one declared. Try to// provide a useful error message.// add a newline to separate from other console output.console.log('\nERROR: Mapping for character "' + e.which + '" does not match tests.');- throw err;+ throw error;}}diff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.jsindex 2337a97cbd3..89e6a2527d8 100644--- a/frontend_tests/node_tests/util.js+++ b/frontend_tests/node_tests/util.js@@ -111,8 +111,8 @@ run_test("robust_uri_decode", () => {});try {util.robust_uri_decode("%E0%A4%A");- } catch (e) {- assert.equal(e, "foo");+ } catch (error) {+ assert.equal(error, "foo");}});diff --git a/frontend_tests/puppeteer_lib/common.js b/frontend_tests/puppeteer_lib/common.jsindex 16458c7422e..c834e57df24 100644--- a/frontend_tests/puppeteer_lib/common.js+++ b/frontend_tests/puppeteer_lib/common.js@@ -460,8 +460,8 @@ class CommonUtils {const page = await this.get_page();try {await test_function(page);- } catch (e) {- console.log(e);+ } catch (error) {+ console.log(error);// Take a screenshot, and increment the screenshot_id.await this.screenshot(page, `failure-${this.screenshot_id}`);diff --git a/frontend_tests/zjsunit/index.js b/frontend_tests/zjsunit/index.jsindex a5e432f0a57..662730b75ae 100644--- a/frontend_tests/zjsunit/index.js+++ b/frontend_tests/zjsunit/index.js@@ -143,11 +143,11 @@ try {namespace.restore();Handlebars.HandlebarsEnvironment();});-} catch (e) {- if (e.stack) {- console.info(short_tb(e.stack));+} catch (error) {+ if (error.stack) {+ console.info(short_tb(error.stack));} else {- console.info(e);+ console.info(error);}process.exit(1);}diff --git a/static/js/channel.js b/static/js/channel.jsindex f6bd828d445..c263422fa84 100644--- a/static/js/channel.js+++ b/static/js/channel.js@@ -55,11 +55,11 @@ function call(args, idempotent) {save_compose: true,});}- } catch (ex) {+ } catch (error) {blueslip.error("Unexpected 403 response from server",{xhr: xhr.responseText, args},- ex.stack,+ error.stack,);}}diff --git a/static/js/markdown.js b/static/js/markdown.jsindex 945c3e97e5e..0a78eef99df 100644--- a/static/js/markdown.js+++ b/static/js/markdown.js@@ -401,12 +401,12 @@ function handleRealmFilter(pattern, matches) {function handleTex(tex, fullmatch) {try {return katex.renderToString(tex);- } catch (ex) {- if (ex.message.startsWith("KaTeX parse error")) {+ } catch (error) {+ if (error.message.startsWith("KaTeX parse error")) {// TeX syntax errorreturn '<span class="tex-error">' + _.escape(fullmatch) + "</span>";}- blueslip.error(ex);+ blueslip.error(error);return undefined;}}@@ -460,11 +460,11 @@ function python_to_js_filter(pattern, url) {let final_regex = null;try {final_regex = new RegExp(pattern, js_flags);- } catch (ex) {+ } catch (error) {// We have an error computing the generated regex syntax.// We'll ignore this realm filter for now, but log this// failure for debugging later.- blueslip.error("python_to_js_filter: " + ex.message);+ blueslip.error("python_to_js_filter: " + error.message);}return [final_regex, url];}diff --git a/static/js/reload.js b/static/js/reload.jsindex fa0408d4173..1ba7cccbdca 100644--- a/static/js/reload.js+++ b/static/js/reload.js@@ -141,10 +141,10 @@ exports.initialize = function () {if (send_now) {compose.finish();}- } catch (err) {+ } catch (error) {// We log an error if we can't open the compose box, but otherwise// we continue, since this is not critical.- blueslip.warn(err.toString());+ blueslip.warn(error.toString());}}@@ -181,8 +181,8 @@ function do_reload_app(send_after_reload, save_pointer, save_narrow, save_composif (save_pointer || save_narrow || save_compose) {try {preserve_state(send_after_reload, save_pointer, save_narrow, save_compose);- } catch (ex) {- blueslip.error("Failed to preserve state", undefined, ex.stack);+ } catch (error) {+ blueslip.error("Failed to preserve state", undefined, error.stack);}}@@ -212,8 +212,8 @@ function do_reload_app(send_after_reload, save_pointer, save_narrow, save_compostry {server_events.cleanup_event_queue();- } catch (ex) {- blueslip.error("Failed to cleanup before reloading", undefined, ex.stack);+ } catch (error) {+ blueslip.error("Failed to cleanup before reloading", undefined, error.stack);}window.location.reload(true);diff --git a/static/js/server_events.js b/static/js/server_events.jsindex 523d3a6a66c..d7b00c4f929 100644--- a/static/js/server_events.js+++ b/static/js/server_events.js@@ -31,8 +31,12 @@ function get_events_success(events) {for (const event of events) {try {get_events_params.last_event_id = Math.max(get_events_params.last_event_id, event.id);- } catch (ex) {- blueslip.error("Failed to update last_event_id", {event: clean_event(event)}, ex.stack);+ } catch (error) {+ blueslip.error(+ "Failed to update last_event_id",+ {event: clean_event(event)},+ error.stack,+ );}}@@ -81,11 +85,11 @@ function get_events_success(events) {for (const event of events) {try {dispatch_event(event);- } catch (ex1) {+ } catch (error) {blueslip.error(- "Failed to process an event\n" + blueslip.exception_msg(ex1),+ "Failed to process an event\n" + blueslip.exception_msg(error),{event: clean_event(event)},- ex1.stack,+ error.stack,);}}@@ -113,11 +117,11 @@ function get_events_success(events) {message_events.insert_new_messages(messages, sent_by_this_client);}- } catch (ex2) {+ } catch (error) {blueslip.error(- "Failed to insert new messages\n" + blueslip.exception_msg(ex2),+ "Failed to insert new messages\n" + blueslip.exception_msg(error),undefined,- ex2.stack,+ error.stack,);}}@@ -129,11 +133,11 @@ function get_events_success(events) {if (update_message_events.length !== 0) {try {message_events.update_messages(update_message_events);- } catch (ex3) {+ } catch (error) {blueslip.error(- "Failed to update messages\n" + blueslip.exception_msg(ex3),+ "Failed to update messages\n" + blueslip.exception_msg(error),undefined,- ex3.stack,+ error.stack,);}}@@ -208,11 +212,11 @@ function get_events(options) {hide_ui_connection_error();get_events_success(data.events);- } catch (ex) {+ } catch (error) {blueslip.error(- "Failed to handle get_events success\n" + blueslip.exception_msg(ex),+ "Failed to handle get_events success\n" + blueslip.exception_msg(error),undefined,- ex.stack,+ error.stack,);}get_events_timeout = setTimeout(get_events, 0);@@ -251,11 +255,11 @@ function get_events(options) {} else {hide_ui_connection_error();}- } catch (ex) {+ } catch (error) {blueslip.error(- "Failed to handle get_events error\n" + blueslip.exception_msg(ex),+ "Failed to handle get_events error\n" + blueslip.exception_msg(error),undefined,- ex.stack,+ error.stack,);}const retry_sec = Math.min(90, Math.exp(get_events_failures / 2));diff --git a/static/js/submessage.js b/static/js/submessage.jsindex 9a40832435d..1cef93d8edd 100644--- a/static/js/submessage.js+++ b/static/js/submessage.js@@ -28,8 +28,8 @@ exports.process_submessages = function (in_opts) {// damage that may be triggered by one rogue message.try {return exports.do_process_submessages(in_opts);- } catch (err) {- blueslip.error("in process_submessages: " + err.message);+ } catch (error) {+ blueslip.error("in process_submessages: " + error.message);return undefined;}};diff --git a/static/js/util.js b/static/js/util.jsindex ec4ceb9171b..29818ab12ee 100644--- a/static/js/util.js+++ b/static/js/util.js@@ -125,9 +125,9 @@ exports.robust_uri_decode = function (str) {while (end > 0) {try {return decodeURIComponent(str.slice(0, end));- } catch (e) {- if (!(e instanceof URIError)) {- throw e;+ } catch (error) {+ if (!(error instanceof URIError)) {+ throw error;}end -= 1;}diff --git a/tools/message-screenshot.js b/tools/message-screenshot.jsindex 63fba2dd6bc..db05cff0268 100644--- a/tools/message-screenshot.js+++ b/tools/message-screenshot.js@@ -70,8 +70,8 @@ async function run() {const imageDir = path.dirname(imagePath);mkdirp.sync(imageDir);await page.screenshot({path: imagePath, clip});- } catch (e) {- console.log(e);+ } catch (error) {+ console.log(error);process.exit(1);} finally {await browser.close();