Skip to content

Commit ed9d333

Browse files
committed
feat(interfaces): ErrInvalidUrl
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent bd7c873 commit ed9d333

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ This package is fully typed with [TypeScript][12]. It exports the following defi
570570

571571
### Interfaces
572572

573+
- [`ErrInvalidUrl`](src/interfaces/err-invalid-url.ts)
573574
- [`ErrnoException`](src/interfaces/errno-exception.ts)
574575

575576
### Type Definitions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @file Type Tests - ErrInvalidUrl
3+
* @module errnode/interfaces/tests/unit-d/ErrInvalidUrl
4+
*/
5+
6+
import type { ErrorCode } from '#src/enums'
7+
import type { NodeError } from '#src/types'
8+
import type TestSubject from '../err-invalid-url'
9+
10+
describe('unit-d:interfaces/ErrInvalidUrl', () => {
11+
it('should extend NodeError<TypeError>', () => {
12+
expectTypeOf<TestSubject>().toMatchTypeOf<NodeError<TypeError>>()
13+
})
14+
15+
it('should match [code: ErrorCode.ERR_INVALID_URL]', () => {
16+
expectTypeOf<TestSubject>()
17+
.toHaveProperty('code')
18+
.toEqualTypeOf<ErrorCode.ERR_INVALID_URL>()
19+
})
20+
21+
it('should match [input: string]', () => {
22+
expectTypeOf<TestSubject>().toHaveProperty('input').toBeString()
23+
})
24+
})

src/interfaces/err-invalid-url.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @file Interfaces - ErrInvalidUrl
3+
* @module errnode/interfaces/ErrInvalidUrl
4+
*/
5+
6+
import type { ErrorCode } from '#src/enums'
7+
import type { NodeError } from '#src/types'
8+
9+
/**
10+
* [`ERR_INVALID_URL`][1] schema.
11+
*
12+
* [1]: https://nodejs.org/api/errors.html#err_invalid_url
13+
*
14+
* @extends {NodeError<TypeError>}
15+
*/
16+
interface ErrInvalidUrl extends NodeError<TypeError> {
17+
/**
18+
* Error code.
19+
*/
20+
code: ErrorCode.ERR_INVALID_URL
21+
22+
/**
23+
* URL that failed to parse.
24+
*
25+
* @example
26+
* 'http://[127.0.0.1\x00c8763]:8000/'
27+
*/
28+
input: string
29+
}
30+
31+
export type { ErrInvalidUrl as default }

src/interfaces/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
* @module errnode/interfaces
44
*/
55

6+
export type { default as ErrInvalidUrl } from './err-invalid-url'
67
export type { default as ErrnoException } from './errno-exception'

0 commit comments

Comments
 (0)