File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed
browser-extension/src/scripts Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -33,24 +33,20 @@ const fetchResponse = async (url: string, options?: RequestInit) => {
3333 return ret
3434}
3535
36- export class HttpServiceError extends Error {
37- detail ?: string
36+ function errorWithDetail < T extends new ( ...args : any [ ] ) => any > ( Base : T ) {
37+ return class extends Base {
38+ detail ?: string
3839
39- constructor ( detail ?: string ) {
40- super ( )
41- this . detail = detail
40+ constructor ( ...args : any [ ] ) {
41+ super ( args [ 0 ] )
42+ this . detail = args [ 0 ]
43+ }
4244 }
43-
4445}
4546
46- export class NetworkError extends TypeError {
47- detail ?: string
47+ export class HttpServiceError extends errorWithDetail ( Error ) { }
4848
49- constructor ( detail ?: string ) {
50- super ( )
51- this . detail = detail
52- }
53- }
49+ export class NetworkError extends errorWithDetail ( TypeError ) { }
5450
5551export async function * fetchStreamJson ( url : string , options ?: RequestInit ) : AsyncIterable < any > {
5652 let resp = await fetchResponse ( url , options )
You can’t perform that action at this time.
0 commit comments