@adp-psych/container-tools
Version:
Tools for using containers for psychology experiments
47 lines (43 loc) • 1.66 kB
JavaScript
/*
* Copyright (C) 2021 Anthony Di Pietro
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* @file Throws an error for a missing value in `package.json`.
*
* @module module:missing-value-error
* @author Anthony Di Pietro <anthony.dipietro@research.uwa.edu.au>
* @copyright © 2021 Anthony Di Pietro
* @license AGPL-3.0-or-later
*/
/**
* Throws an error for a missing value in `package.json`.
*
* @static
* @access protected
* @param {String} description - The description of the missing value.
* @param {String} setting - The name of the setting in `package.json`.
* @throws {Error} Throws an error if a value is missing.
* @example
* // Error: 'No author email defined. Set author in package.json.'.
* missingValueError('author email', 'author');
*/
const missingValueError = (description, setting) => {
/* eslint-disable-next-line fp/no-throw -- Convenient error messages. */
throw new Error(
`No ${description} defined. Set "${setting}" in package.json.`,
);
};
module.exports = missingValueError;