File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ import {
4747} from '@the-draupnir-project/matrix-basic-types' ;
4848import { resolveRoomReferenceSafe } from '../SafeMatrixClient' ;
4949import { ResultError } from '@gnuxie/typescript-result' ;
50+ import util from 'util' ;
5051
5152const log = new Logger ( 'BotSDKBaseClient' ) ;
5253
@@ -80,10 +81,26 @@ function actionExceptionFromWeakError(
8081}
8182
8283function unknownError ( error : unknown ) : never {
84+ const printedError = ( ( ) => {
85+ if ( typeof error === 'object' && error !== null ) {
86+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
87+ const toString = error . toString ( ) ;
88+ if ( toString !== '[object Object]' ) {
89+ return toString ;
90+ }
91+ }
92+ try {
93+ return JSON . stringify ( error ) ;
94+ } catch {
95+ return util . inspect ( error , {
96+ depth : 2 ,
97+ maxArrayLength : 10 ,
98+ breakLength : 80 ,
99+ } ) ;
100+ }
101+ } ) ( ) ;
83102 throw new TypeError (
84- // Not sure what to do yet other than throw?
85- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
86- `What on earth are you throwing exactly? because it isn't an error ${ error } `
103+ `What on earth are you throwing exactly? because it isn't an error: ${ printedError } `
87104 ) ;
88105}
89106
You can’t perform that action at this time.
0 commit comments