Skip to content

Commit c9f6395

Browse files
committed
Add isOptions
1 parent dfea2d7 commit c9f6395

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import type { Info, Plugin } from 'modern-errors'
66
*/
77
export type { Options }
88

9+
// `error.beautiful()` is called with `errorString` as argument by
10+
// `beautiful-error`. We ignore that argument and prevent it from being
11+
// considered an invalid options object.
12+
const isOptions = (options: unknown) => typeof options !== 'string'
13+
914
const getOptions = (options: Options = {}) => {
1015
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1116
validateOptions(options)
@@ -41,6 +46,7 @@ const beautiful = ({ error, options }: Info<Options>['instanceMethods']) =>
4146
*/
4247
const modernErrorsBeautiful = {
4348
name: 'beautiful' as const,
49+
isOptions,
4450
getOptions,
4551
instanceMethods: { beautiful },
4652
} satisfies Plugin

0 commit comments

Comments
 (0)