From 867f73b80ac13546560f6e390ff919921b320424 Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Fri, 23 Mar 2018 18:24:50 -0400 Subject: [PATCH] Use double quotes for identifiers in error messages --- js/modules/privacy.js | 6 +++--- js/modules/string_to_array_buffer.js | 2 +- js/modules/types/attachment.js | 12 ++++++------ .../types/attachment/migrate_data_to_file_system.js | 2 +- js/modules/types/message.js | 4 ++-- test/modules/types/message_test.js | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/js/modules/privacy.js b/js/modules/privacy.js index db0529376eb2..9e5f266460cb 100644 --- a/js/modules/privacy.js +++ b/js/modules/privacy.js @@ -27,7 +27,7 @@ const REDACTION_PLACEHOLDER = '[REDACTED]'; // redactPhoneNumbers :: String -> String exports.redactPhoneNumbers = (text) => { if (!isString(text)) { - throw new TypeError('`text` must be a string'); + throw new TypeError('"text" must be a string'); } return text.replace(PHONE_NUMBER_PATTERN, `+${REDACTION_PLACEHOLDER}$1`); @@ -36,7 +36,7 @@ exports.redactPhoneNumbers = (text) => { // redactGroupIds :: String -> String exports.redactGroupIds = (text) => { if (!isString(text)) { - throw new TypeError('`text` must be a string'); + throw new TypeError('"text" must be a string'); } return text.replace( @@ -49,7 +49,7 @@ exports.redactGroupIds = (text) => { // redactSensitivePaths :: String -> String exports.redactSensitivePaths = (text) => { if (!isString(text)) { - throw new TypeError('`text` must be a string'); + throw new TypeError('"text" must be a string'); } if (!isRegExp(APP_ROOT_PATH_PATTERN)) { diff --git a/js/modules/string_to_array_buffer.js b/js/modules/string_to_array_buffer.js index 9d147c4f8a77..4c6fa700cd91 100644 --- a/js/modules/string_to_array_buffer.js +++ b/js/modules/string_to_array_buffer.js @@ -1,6 +1,6 @@ exports.stringToArrayBuffer = (string) => { if (typeof string !== 'string') { - throw new TypeError('`string` must be a string'); + throw new TypeError('"string" must be a string'); } const array = new Uint8Array(string.length); diff --git a/js/modules/types/attachment.js b/js/modules/types/attachment.js index 7dcb4906d49c..cb257c212a13 100644 --- a/js/modules/types/attachment.js +++ b/js/modules/types/attachment.js @@ -121,12 +121,12 @@ exports.hasData = attachment => // IO (Promise Attachment) exports.loadData = (readAttachmentData) => { if (!isFunction(readAttachmentData)) { - throw new TypeError('`readAttachmentData` must be a function'); + throw new TypeError('"readAttachmentData" must be a function'); } return async (attachment) => { if (!exports.isValid(attachment)) { - throw new TypeError('`attachment` is not valid'); + throw new TypeError('"attachment" is not valid'); } const isAlreadyLoaded = exports.hasData(attachment); @@ -135,7 +135,7 @@ exports.loadData = (readAttachmentData) => { } if (!isString(attachment.path)) { - throw new TypeError('`attachment.path` is required'); + throw new TypeError('"attachment.path" is required'); } const data = await readAttachmentData(attachment.path); @@ -148,12 +148,12 @@ exports.loadData = (readAttachmentData) => { // IO Unit exports.deleteData = (deleteAttachmentData) => { if (!isFunction(deleteAttachmentData)) { - throw new TypeError('`deleteAttachmentData` must be a function'); + throw new TypeError('"deleteAttachmentData" must be a function'); } return async (attachment) => { if (!exports.isValid(attachment)) { - throw new TypeError('`attachment` is not valid'); + throw new TypeError('"attachment" is not valid'); } const hasDataInMemory = exports.hasData(attachment); @@ -162,7 +162,7 @@ exports.deleteData = (deleteAttachmentData) => { } if (!isString(attachment.path)) { - throw new TypeError('`attachment.path` is required'); + throw new TypeError('"attachment.path" is required'); } await deleteAttachmentData(attachment.path); diff --git a/js/modules/types/attachment/migrate_data_to_file_system.js b/js/modules/types/attachment/migrate_data_to_file_system.js index d57ca4128ccc..ed21cb2ababd 100644 --- a/js/modules/types/attachment/migrate_data_to_file_system.js +++ b/js/modules/types/attachment/migrate_data_to_file_system.js @@ -13,7 +13,7 @@ const omit = require('lodash/omit'); // Promise Attachment exports.migrateDataToFileSystem = async (attachment, { writeAttachmentData } = {}) => { if (!isFunction(writeAttachmentData)) { - throw new TypeError('`writeAttachmentData` must be a function'); + throw new TypeError('"writeAttachmentData" must be a function'); } const { data } = attachment; diff --git a/js/modules/types/message.js b/js/modules/types/message.js index 01cb67db5383..b4680818ffbe 100644 --- a/js/modules/types/message.js +++ b/js/modules/types/message.js @@ -81,10 +81,10 @@ exports.initializeSchemaVersion = (message) => { // SchemaVersion -> UpgradeStep -> UpgradeStep exports._withSchemaVersion = (schemaVersion, upgrade) => { if (!SchemaVersion.isValid(schemaVersion)) { - throw new TypeError('`schemaVersion` is invalid'); + throw new TypeError('"schemaVersion" is invalid'); } if (!isFunction(upgrade)) { - throw new TypeError('`upgrade` must be a function'); + throw new TypeError('"upgrade" must be a function'); } return async (message, context) => { diff --git a/test/modules/types/message_test.js b/test/modules/types/message_test.js index ef0263bd6fde..a6afc05164e1 100644 --- a/test/modules/types/message_test.js +++ b/test/modules/types/message_test.js @@ -183,14 +183,14 @@ describe('Message', () => { const toVersionX = () => {}; assert.throws( () => Message._withSchemaVersion(toVersionX, 2), - '`schemaVersion` is invalid' + '"schemaVersion" is invalid' ); }); it('should require an upgrade function', () => { assert.throws( () => Message._withSchemaVersion(2, 3), - '`upgrade` must be a function' + '"upgrade" must be a function' ); });