Skip to content

Commit 8eb9969

Browse files
authoredJun 10, 2022
feat(createError): support string as error source (#132)
1 parent bf8a329 commit 8eb9969

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/error.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ export class H3Error extends Error {
2323
* @param input {Partial<H3Error>}
2424
* @return {H3Error} An instance of the H3Error
2525
*/
26-
export function createError (input: Partial<H3Error>): H3Error {
26+
export function createError (input: string | Partial<H3Error>): H3Error {
27+
if (typeof input === 'string') {
28+
return new H3Error(input)
29+
}
30+
2731
if (input instanceof H3Error) {
2832
return input
2933
}

0 commit comments

Comments
 (0)
Please sign in to comment.