@foundry-ai/api-errors
Version:
Common errors that can be thrown and caught reliably across services
27 lines (19 loc) • 988 B
text/typescript
import { suite, test } from 'mocha-typescript';
import { expect } from 'chai';
import { InternalError } from '../src/internalError';
class InternalErrorDefaults {
public error: InternalError;
before() { this.error = new InternalError(); }
name() { expect(this.error.name).to.equal('InternalError'); }
type() { expect(this.error.type).to.equal('internal_error'); }
message() { expect(this.error.message).to.equal('Internal Server Error'); }
status() { expect(this.error.status).to.equal(500); }
}
class InternalErrorCustom {
public error: InternalError;
before() { this.error = new InternalError('custom message', 999); }
name() { expect(this.error.name).to.equal('InternalError'); }
type() { expect(this.error.type).to.equal('internal_error'); }
message() { expect(this.error.message).to.equal('custom message'); }
status() { expect(this.error.status).to.equal(999); }
}