@@ -12,7 +12,7 @@ import { generateSPKIFingerprint } from 'mockttp';
12
12
13
13
import { HtkConfig } from './config' ;
14
14
import { reportError , addBreadcrumb } from './error-tracking' ;
15
- import { buildInterceptors , Interceptor } from './interceptors' ;
15
+ import { buildInterceptors , Interceptor , ActivationError } from './interceptors' ;
16
16
import { ALLOWED_ORIGINS } from './constants' ;
17
17
import { delay } from './util' ;
18
18
@@ -88,6 +88,8 @@ const withFallback = <R>(p: Promise<R>, timeoutMs: number, defaultValue: R) =>
88
88
delay ( timeoutMs ) . then ( ( ) => defaultValue )
89
89
] ) ;
90
90
91
+ const isActivationError = ( value : any ) : value is ActivationError => _ . isError ( value ) ;
92
+
91
93
const INTERCEPTOR_TIMEOUT = 1000 ;
92
94
93
95
const buildResolvers = (
@@ -128,9 +130,9 @@ const buildResolvers = (
128
130
const result = await interceptor . activate ( proxyPort , options ) . catch ( ( e ) => e ) ;
129
131
activationDone = true ;
130
132
131
- if ( _ . isError ( result ) ) {
132
- reportError ( result ) ;
133
- return { success : false } ;
133
+ if ( isActivationError ( result ) ) {
134
+ if ( result . reportable !== false ) reportError ( result ) ;
135
+ return { success : false , metadata : result . metadata } ;
134
136
} else {
135
137
addBreadcrumb ( `Successfully activated ${ id } ` , { category : 'interceptor' } ) ;
136
138
return { success : true , metadata : result } ;
0 commit comments