File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ debug.formatters.a = (v?: Multiaddr): string => {
79
79
80
80
// Add a formatter for stringifying Errors
81
81
debug . formatters . e = ( v ?: Error ) : string => {
82
- return v == null ? 'undefined' : v . stack ?? v . message
82
+ return v == null ? 'undefined' : notEmpty ( v . stack ) ?? notEmpty ( v . message ) ?? v . toString ( )
83
83
}
84
84
85
85
export interface Logger {
@@ -220,3 +220,17 @@ export function enable (namespaces: string): void {
220
220
export function enabled ( namespaces : string ) : boolean {
221
221
return debug . enabled ( namespaces )
222
222
}
223
+
224
+ function notEmpty ( str ?: string ) : string | undefined {
225
+ if ( str == null ) {
226
+ return
227
+ }
228
+
229
+ str = str . trim ( )
230
+
231
+ if ( str . length === 0 ) {
232
+ return
233
+ }
234
+
235
+ return str
236
+ }
You can’t perform that action at this time.
0 commit comments