11import * as FridaJs from 'frida-js' ;
2+ import { CustomError } from '@httptoolkit/util' ;
23
34import { getReachableInterfaces } from '../../util/network' ;
45import { buildIpTestScript } from './frida-scripts' ;
5- import { ErrorWithCode } from '../../util/error' ;
66
77/**
88 * Terminology:
@@ -46,7 +46,11 @@ export async function testAndSelectProxyAddress(
4646 ips . push ( ...options . extraAddresses ) ;
4747 }
4848
49- if ( ips . length === 0 ) throw new ErrorWithCode ( 'unreachable-proxy' , "Couldn't detect proxy external IP" ) ;
49+ if ( ips . length === 0 ) {
50+ throw new CustomError ( "Couldn't detect proxy external IP" , {
51+ code : 'unreachable-proxy'
52+ } ) ;
53+ }
5054
5155 const ipTestScript = await buildIpTestScript ( ips , proxyPort ) ;
5256
@@ -57,13 +61,11 @@ export async function testAndSelectProxyAddress(
5761 if ( message . payload . type === 'connected' ) {
5862 resolve ( message . payload . ip as string ) ;
5963 } else if ( message . payload . type === 'connection-failed' ) {
60- reject ( new ErrorWithCode ( 'unreachable-proxy' ,
61- `Could not connect to proxy on port ${ proxyPort } at ${
62- ips . length > 1
63- ? `any of: ${ ips . join ( ', ' ) } `
64- : ips [ 0 ]
65- } `
66- ) ) ;
64+ reject ( new CustomError ( `Could not connect to proxy on port ${ proxyPort } at ${
65+ ips . length > 1
66+ ? `any of: ${ ips . join ( ', ' ) } `
67+ : ips [ 0 ]
68+ } `, { code : 'unreachable-proxy' } ) ) ;
6769 } else {
6870 reject ( new Error ( `Unexpected message type: ${ message . payload . type } ` ) ) ;
6971 }
0 commit comments