Skip to content

Commit 5f91113

Browse files
committed
Return error if it is not defined
1 parent 80ae047 commit 5f91113

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FormatError {
2828
const error = this.errorType[err.message]
2929

3030
if (!error) {
31-
throw new Error(`${err.message} error is not defined on easygraphql-formatError`)
31+
return err
3232
}
3333

3434
return error

test/errors.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,5 @@ describe('Get Errors with message and code', () => {
5656
expect(error.statusCode).to.be.eq(400)
5757
}
5858
})
59-
60-
it('Should get Invalid email format error with the statusCode', async () => {
61-
let error
62-
try {
63-
formatError.getError({ message: 'Invalid email' })
64-
} catch (err) {
65-
error = err
66-
}
67-
68-
if (!error) {
69-
throw new Error('There should be an error')
70-
}
71-
72-
expect(error.message).to.be.eq('Invalid email error is not defined on easygraphql-formatError')
73-
})
7459
})
7560
})

0 commit comments

Comments
 (0)