fix(rpc): nice error stacks when running tests (#3507)
This commit is contained in:
parent
c2cd963407
commit
4e5007ae1a
|
|
@ -19,6 +19,7 @@ import * as channels from '../protocol/channels';
|
||||||
import type { Connection } from './connection';
|
import type { Connection } from './connection';
|
||||||
import type { Logger } from './types';
|
import type { Logger } from './types';
|
||||||
import { debugLogger } from '../utils/debugLogger';
|
import { debugLogger } from '../utils/debugLogger';
|
||||||
|
import { isDevMode } from '../utils/utils';
|
||||||
|
|
||||||
export abstract class ChannelOwner<T extends channels.Channel = channels.Channel, Initializer = {}> extends EventEmitter {
|
export abstract class ChannelOwner<T extends channels.Channel = channels.Channel, Initializer = {}> extends EventEmitter {
|
||||||
private _connection: Connection;
|
private _connection: Connection;
|
||||||
|
|
@ -99,10 +100,9 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel
|
||||||
return result;
|
return result;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logApiCall(logger, `<= ${apiName} failed`);
|
logApiCall(logger, `<= ${apiName} failed`);
|
||||||
// TODO: we could probably save "e.stack" in some log-heavy mode
|
const innerStack = (isDevMode() && e.stack) ? e.stack.substring(e.stack.indexOf(e.message) + e.message.length) : '';
|
||||||
// because it gives some insights into the server part.
|
|
||||||
e.message = `${apiName}: ` + e.message;
|
e.message = `${apiName}: ` + e.message;
|
||||||
e.stack = e.message + stack;
|
e.stack = e.message + innerStack + stack;
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue