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
8383 * @returns A wrapped version of that logger
8484 */
8585function makeWrappedErrorLogger ( origErrorLogger : ErrorLogger ) : WrappedErrorLogger {
86- return ( err : Error ) : void => {
86+ return function ( this : Server , err : Error ) : void {
8787 // TODO add context data here
8888 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 ) ;
9290 } ;
9391}
Original file line number Diff line number Diff line change @@ -8,12 +8,14 @@ import { getFunctionName } from './stacktrace';
88import { truncate } from './string' ;
99
1010/**
11- * Wrap a given object method with a higher-order function
11+ * Replace a method in an object with a wrapped version of itself.
1212 *
1313 * @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`.
1719 * @returns void
1820 */
1921export 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