Inital build
Some checks failed
Automated Container Build / build-and-push (push) Failing after 12s

This commit is contained in:
Elijah 2026-05-22 12:29:43 -07:00
parent fa2be029a2
commit 724d70e58b
3339 changed files with 1075535 additions and 0 deletions

View file

@ -0,0 +1,25 @@
"use strict";
var CustomError = require('../index');
var store = {};
var Err = CustomError('MapError');
Err.inuse = CustomError(Err, { message: 'The specified key is already in use.', code: 'INUSE' });
function add(key, value) {
if (Math.random() < .3) throw new Err('Random Error');
if (store.hasOwnProperty(key)) throw new Err.inuse();
store[key] = value;
}
try {
add('x', 1);
add('x', 2);
} catch (e) {
if (e instanceof Err.inuse) {
console.error(e.toString()); // "MapError INUSE: The specified key is already in use."
} else if (e instanceof Err) {
console.error('Unexpected ' + e); // "Unexpected MapError: Random Error"
} else {
throw e;
}
}