UNPKG

@foundry-ai/api-errors

Version:

Common errors that can be thrown and caught reliably across services

27 lines (19 loc) 988 B
import { suite, test } from 'mocha-typescript'; import { expect } from 'chai'; import { InternalError } from '../src/internalError'; @suite class InternalErrorDefaults { public error: InternalError; before() { this.error = new InternalError(); } @test name() { expect(this.error.name).to.equal('InternalError'); } @test type() { expect(this.error.type).to.equal('internal_error'); } @test message() { expect(this.error.message).to.equal('Internal Server Error'); } @test status() { expect(this.error.status).to.equal(500); } } @suite class InternalErrorCustom { public error: InternalError; before() { this.error = new InternalError('custom message', 999); } @test name() { expect(this.error.name).to.equal('InternalError'); } @test type() { expect(this.error.type).to.equal('internal_error'); } @test message() { expect(this.error.message).to.equal('custom message'); } @test status() { expect(this.error.status).to.equal(999); } }