Resolve exception when Error.stackTraceLimit is undefined

Some applications may explicitly set Error.stackTraceLimit = undefined. In this case it is not safe to assume new Error().stack is available.
This commit is contained in:
David Fiala 2024-03-27 16:39:45 -07:00 committed by Michael Lumish
parent 729a3f52cf
commit 213230c73b
1 changed files with 1 additions and 1 deletions

View File

@ -110,7 +110,7 @@ export type ClientOptions = Partial<ChannelOptions> & {
};
function getErrorStackString(error: Error): string {
return error.stack!.split('\n').slice(1).join('\n');
return error.stack?.split('\n').slice(1).join('\n') || 'no stack trace available';
}
/**