diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js index 499752bcb1..8768baf23d 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.js index 2337a97cbd..89e6a2527d 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.js index 16458c7422..c834e57df2 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.js index a5e432f0a5..662730b75a 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.js index f6bd828d44..c263422fa8 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.js index 945c3e97e5..0a78eef99d 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 error return '' + _.escape(fullmatch) + ""; } - 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.js index fa0408d417..1ba7cccbdc 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_compos if (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_compos try { 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.js index 523d3a6a66..d7b00c4f92 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.js index 9a40832435..1cef93d8ed 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.js index ec4ceb9171..29818ab12e 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.js index 63fba2dd6b..db05cff026 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();