Use double quotes for identifiers in error messages
This commit is contained in:
parent
06e7bca276
commit
867f73b80a
6 changed files with 15 additions and 15 deletions
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue