Skip to content

Commit

Permalink
chore: mark validation error as user error (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed Mar 20, 2023
1 parent be10344 commit 4dec1b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions node/validation/manifest/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export default class ManifestValidationError extends Error {
customErrorInfo = {
type: 'functionsBundling',
}

constructor(message: string | undefined) {
super(`Validation of Edge Functions manifest failed\n${message}`)

Expand Down
15 changes: 15 additions & 0 deletions node/validation/manifest/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ test('should throw ManifestValidationError with correct message', () => {
expect(() => validateManifest('manifest')).toThrowError(/^Validation of Edge Functions manifest failed/)
})

test('should throw ManifestValidationError with customErrorInfo', () => {
try {
validateManifest('manifest')
} catch (error) {
expect(error).toBeInstanceOf(ManifestValidationError)

const { customErrorInfo } = error as ManifestValidationError
expect(customErrorInfo).toBeDefined()
expect(customErrorInfo.type).toBe('functionsBundling')
return
}

expect.fail('should have thrown')
})

test('should throw on additional property on root level', () => {
const manifest = getBaseManifest()
manifest.foo = 'bar'
Expand Down

0 comments on commit 4dec1b9

Please sign in to comment.