How to use errlop - 7 common examples

To help you get started, we’ve selected a few errlop examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bevry / boundation / source / answers.js View on Github external
}
				return !reason
			}
		})

		// get answers
		const answers = await inquirer.prompt(questions)

		// merge in defaults
		const values = Object.assign({}, defaults, answers)

		// return merge
		return values
	} catch (err) {
		return Promise.reject(
			new Errlop('Failed to fetch the answers from the user', err)
		)
	}
}
github bevry / editions / source / index.ts View on Github external
'unsupported-edition-engines-node-version'
				) === 0
			) {
				fallbackEdition = edition
			}
		}
	}

	// if no edition was suitable for our environment, then try the fallback if it exists
	// that is to say, ignore its engines.node
	if (opts.strict === false && loaded === false && fallbackEdition) {
		try {
			result = loadEdition(fallbackEdition, opts)
			loaded = true
		} catch (editionError) {
			editionsError = new Errlop(editionError, editionsError)
		}
	}

	// if we were able to load something, then provide it
	if (loaded) {
		// make note of any errors if desired
		if (editionsError && verbose) {
			const stderr = opts.stderr || process.stderr
			stderr.write(editionsError.stack + '\n')
		}
		return result
	}
	// otherwise, provide the error
	else if (editionsError) {
		if (opts.packagePath) {
			throw errtion(
github bevry / boundation / source / extensions.js View on Github external
process.on('unhandledRejection', function unhandledRejection(error) {
	console.error(new Errlop('An unhandled promise failed', error))
	process.exit(-1)
})
github bevry / boundation / source / base.js View on Github external
/^# CUSTOM/i.test(line)
			)
			if (localCustomIndex !== -1) {
				const remoteLines = data.split('\n')
				const remoteCustomIndex = remoteLines.findIndex(line =>
					/^# CUSTOM/i.test(line)
				)
				data = remoteLines
					.slice(0, remoteCustomIndex)
					.concat(localLines.slice(localCustomIndex))
					.join('\n')
			}
		}
		return write(file, data)
	} catch (err) {
		return Promise.reject(new Errlop(`Download of ${opts.url} FAILED`, err))
	}
}
github bevry / boundation / source / get-node.js View on Github external
async function getNodeLTSVersions() {
	const url =
		'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json'
	try {
		const response = await fetch(url)
		const json = await response.json()
		const lts = Object.entries(json)
		return lts
	} catch (err) {
		throw new Errlop(`failed to fetch node.js LTS releases from ${url}`, err)
	}
}
async function getMinimumNodeLTSVersion() {
github bevry / boundation / source / fs.js View on Github external
safeps.exec(command, opts, function(err, stdout) {
			if (err) return reject(new Errlop(`exec failed: ${command}`, err))
			return resolve(stdout)
		})
	})
github bevry / editions / source / util.js View on Github external
function errtion({ message, code, level }, parent) {
	if (this) throw new Error('errtion is not to be created with new')
	const error = new Errlop(message, parent)
	if (code) error.code = code
	if (level) error.level = level
	return error
}

errlop

An extended Error class that envelops a parent error, such that the stack trace contains the causation

Artistic-2.0
Latest version published 11 months ago

Package Health Score

74 / 100
Full package analysis