succulent
Version:
Powerful and easy runtime type checking
29 lines • 683 B
JavaScript
import { trace } from "./trace";
export class KeyReporter {
check;
onError;
constructor(check, onError) {
this.check = check;
this.onError = onError;
}
errorTraces = [];
reset() {
if (this.errorTraces.length > 0) {
this.errorTraces = [];
}
}
report(...args) {
try {
this.check(...args);
}
catch (error) {
this.errorTraces.push(trace(this.onError(...args), error));
}
}
resolve() {
if (this.errorTraces.length > 0) {
throw new TypeError(this.errorTraces.join("\n"));
}
}
}
//# sourceMappingURL=keyReporter.js.map