@foundry-ai/api-errors
Version:
Common errors that can be thrown and caught reliably across services
27 lines (19 loc) • 1.05 kB
text/typescript
import { suite, test } from 'mocha-typescript';
import { expect } from 'chai';
import { AuthenticationError } from '../src/authenticationError';
class AuthenticationErrorDefaults {
public error: AuthenticationError;
before() { this.error = new AuthenticationError(); }
name() { expect(this.error.name).to.equal('AuthenticationError'); }
type() { expect(this.error.type).to.equal('authentication_error'); }
message() { expect(this.error.message).to.equal('Unauthorized'); }
status() { expect(this.error.status).to.equal(401); }
}
class AuthenticationErrorCustom {
public error: AuthenticationError;
before() { this.error = new AuthenticationError('custom message', 999); }
name() { expect(this.error.name).to.equal('AuthenticationError'); }
type() { expect(this.error.type).to.equal('authentication_error'); }
message() { expect(this.error.message).to.equal('custom message'); }
status() { expect(this.error.status).to.equal(999); }
}