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
|
// redactPhoneNumbers :: String -> String
|
||||||
exports.redactPhoneNumbers = (text) => {
|
exports.redactPhoneNumbers = (text) => {
|
||||||
if (!isString(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`);
|
return text.replace(PHONE_NUMBER_PATTERN, `+${REDACTION_PLACEHOLDER}$1`);
|
||||||
|
@ -36,7 +36,7 @@ exports.redactPhoneNumbers = (text) => {
|
||||||
// redactGroupIds :: String -> String
|
// redactGroupIds :: String -> String
|
||||||
exports.redactGroupIds = (text) => {
|
exports.redactGroupIds = (text) => {
|
||||||
if (!isString(text)) {
|
if (!isString(text)) {
|
||||||
throw new TypeError('`text` must be a string');
|
throw new TypeError('"text" must be a string');
|
||||||
}
|
}
|
||||||
|
|
||||||
return text.replace(
|
return text.replace(
|
||||||
|
@ -49,7 +49,7 @@ exports.redactGroupIds = (text) => {
|
||||||
// redactSensitivePaths :: String -> String
|
// redactSensitivePaths :: String -> String
|
||||||
exports.redactSensitivePaths = (text) => {
|
exports.redactSensitivePaths = (text) => {
|
||||||
if (!isString(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)) {
|
if (!isRegExp(APP_ROOT_PATH_PATTERN)) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
exports.stringToArrayBuffer = (string) => {
|
exports.stringToArrayBuffer = (string) => {
|
||||||
if (typeof string !== '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);
|
const array = new Uint8Array(string.length);
|
||||||
|
|
|
@ -121,12 +121,12 @@ exports.hasData = attachment =>
|
||||||
// IO (Promise Attachment)
|
// IO (Promise Attachment)
|
||||||
exports.loadData = (readAttachmentData) => {
|
exports.loadData = (readAttachmentData) => {
|
||||||
if (!isFunction(readAttachmentData)) {
|
if (!isFunction(readAttachmentData)) {
|
||||||
throw new TypeError('`readAttachmentData` must be a function');
|
throw new TypeError('"readAttachmentData" must be a function');
|
||||||
}
|
}
|
||||||
|
|
||||||
return async (attachment) => {
|
return async (attachment) => {
|
||||||
if (!exports.isValid(attachment)) {
|
if (!exports.isValid(attachment)) {
|
||||||
throw new TypeError('`attachment` is not valid');
|
throw new TypeError('"attachment" is not valid');
|
||||||
}
|
}
|
||||||
|
|
||||||
const isAlreadyLoaded = exports.hasData(attachment);
|
const isAlreadyLoaded = exports.hasData(attachment);
|
||||||
|
@ -135,7 +135,7 @@ exports.loadData = (readAttachmentData) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isString(attachment.path)) {
|
if (!isString(attachment.path)) {
|
||||||
throw new TypeError('`attachment.path` is required');
|
throw new TypeError('"attachment.path" is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await readAttachmentData(attachment.path);
|
const data = await readAttachmentData(attachment.path);
|
||||||
|
@ -148,12 +148,12 @@ exports.loadData = (readAttachmentData) => {
|
||||||
// IO Unit
|
// IO Unit
|
||||||
exports.deleteData = (deleteAttachmentData) => {
|
exports.deleteData = (deleteAttachmentData) => {
|
||||||
if (!isFunction(deleteAttachmentData)) {
|
if (!isFunction(deleteAttachmentData)) {
|
||||||
throw new TypeError('`deleteAttachmentData` must be a function');
|
throw new TypeError('"deleteAttachmentData" must be a function');
|
||||||
}
|
}
|
||||||
|
|
||||||
return async (attachment) => {
|
return async (attachment) => {
|
||||||
if (!exports.isValid(attachment)) {
|
if (!exports.isValid(attachment)) {
|
||||||
throw new TypeError('`attachment` is not valid');
|
throw new TypeError('"attachment" is not valid');
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasDataInMemory = exports.hasData(attachment);
|
const hasDataInMemory = exports.hasData(attachment);
|
||||||
|
@ -162,7 +162,7 @@ exports.deleteData = (deleteAttachmentData) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isString(attachment.path)) {
|
if (!isString(attachment.path)) {
|
||||||
throw new TypeError('`attachment.path` is required');
|
throw new TypeError('"attachment.path" is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
await deleteAttachmentData(attachment.path);
|
await deleteAttachmentData(attachment.path);
|
||||||
|
|
|
@ -13,7 +13,7 @@ const omit = require('lodash/omit');
|
||||||
// Promise Attachment
|
// Promise Attachment
|
||||||
exports.migrateDataToFileSystem = async (attachment, { writeAttachmentData } = {}) => {
|
exports.migrateDataToFileSystem = async (attachment, { writeAttachmentData } = {}) => {
|
||||||
if (!isFunction(writeAttachmentData)) {
|
if (!isFunction(writeAttachmentData)) {
|
||||||
throw new TypeError('`writeAttachmentData` must be a function');
|
throw new TypeError('"writeAttachmentData" must be a function');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = attachment;
|
const { data } = attachment;
|
||||||
|
|
|
@ -81,10 +81,10 @@ exports.initializeSchemaVersion = (message) => {
|
||||||
// SchemaVersion -> UpgradeStep -> UpgradeStep
|
// SchemaVersion -> UpgradeStep -> UpgradeStep
|
||||||
exports._withSchemaVersion = (schemaVersion, upgrade) => {
|
exports._withSchemaVersion = (schemaVersion, upgrade) => {
|
||||||
if (!SchemaVersion.isValid(schemaVersion)) {
|
if (!SchemaVersion.isValid(schemaVersion)) {
|
||||||
throw new TypeError('`schemaVersion` is invalid');
|
throw new TypeError('"schemaVersion" is invalid');
|
||||||
}
|
}
|
||||||
if (!isFunction(upgrade)) {
|
if (!isFunction(upgrade)) {
|
||||||
throw new TypeError('`upgrade` must be a function');
|
throw new TypeError('"upgrade" must be a function');
|
||||||
}
|
}
|
||||||
|
|
||||||
return async (message, context) => {
|
return async (message, context) => {
|
||||||
|
|
|
@ -183,14 +183,14 @@ describe('Message', () => {
|
||||||
const toVersionX = () => {};
|
const toVersionX = () => {};
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => Message._withSchemaVersion(toVersionX, 2),
|
() => Message._withSchemaVersion(toVersionX, 2),
|
||||||
'`schemaVersion` is invalid'
|
'"schemaVersion" is invalid'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should require an upgrade function', () => {
|
it('should require an upgrade function', () => {
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => Message._withSchemaVersion(2, 3),
|
() => Message._withSchemaVersion(2, 3),
|
||||||
'`upgrade` must be a function'
|
'"upgrade" must be a function'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue