File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -83,11 +83,9 @@ function makeWrappedHandlerGetter(origHandlerGetter: HandlerGetter): WrappedHand
83
83
* @returns A wrapped version of that logger
84
84
*/
85
85
function makeWrappedErrorLogger ( origErrorLogger : ErrorLogger ) : WrappedErrorLogger {
86
- return ( err : Error ) : void => {
86
+ return function ( this : Server , err : Error ) : void {
87
87
// TODO add context data here
88
88
Sentry . captureException ( err ) ;
89
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
90
- // @ts -ignore
91
- return origErrorLogger . bind ( this , err ) ;
89
+ return origErrorLogger . call ( this , err ) ;
92
90
} ;
93
91
}
Original file line number Diff line number Diff line change @@ -8,12 +8,14 @@ import { getFunctionName } from './stacktrace';
8
8
import { truncate } from './string' ;
9
9
10
10
/**
11
- * Wrap a given object method with a higher-order function
11
+ * Replace a method in an object with a wrapped version of itself.
12
12
*
13
13
* @param source An object that contains a method to be wrapped.
14
- * @param name A name of method to be wrapped.
15
- * @param replacementFactory A function that should be used to wrap a given method, returning the wrapped method which
16
- * will be substituted in for `source[name]`.
14
+ * @param name The name of the method to be wrapped.
15
+ * @param replacementFactory A higher-order function that takes the original version of the given method and returns a
16
+ * wrapped verstion. Note: The function returned by `replacementFactory` needs to be a non-arrow function, in order to
17
+ * preserve the correct value of `this`, and the original method must be called using `origMethod.call(this, <other
18
+ * args>)` or `origMethod.apply(this, [<other args>])` (rather than being called directly), again to preserve `this`.
17
19
* @returns void
18
20
*/
19
21
export function fill ( source : { [ key : string ] : any } , name : string , replacementFactory : ( ...args : any [ ] ) => any ) : void {
You can’t perform that action at this time.
0 commit comments