Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/avaPublic

Add Error .cause property to output #3186

Open
concordancejs/concordance
#91
@Cobertos

Description

@Cobertos

Ava does not currently output an information related theError.cause property.

Error.cause is somewhat new with support in NodeJS 16+, Deno 1.13+, and major browsers since ~September 2021. The.cause property can contain anotherError which is useful when tracing re-throws. But, it can be of any type. It's currently supported .

When youconsole.log such an Error with .cause of another Error in the options, you get something like the following

image

Transcription of above image
Welcome to Node.js v18.12.0.Type ".help" for more information.> function test_a(){ throw new Error('test', { cause: new Error('test cause') }); }undefined> test_a()Uncaught Error: test    at test_a (REPL1:1:26) {  [cause]: Error: test cause      at test_a (REPL1:1:53)      at REPL2:1:1      at Script.runInThisContext (node:vm:129:12)      at REPLServer.defaultEval (node:repl:572:29)      at bound (node:domain:433:15)      at REPLServer.runBound [as eval] (node:domain:444:12)      at REPLServer.onLine (node:repl:902:10)      at REPLServer.emit (node:events:525:35)      at REPLServer.emit (node:domain:489:12)      at [_onLine] [as _onLine] (node:internal/readline/interface:425:12)}>

When.cause is just structured data, a string representation of that data is output after[cause]:

For comparison, in Ava, when you throw an error with a cause, the cause is omitted

image

Transcription of above image
  FnCaster › this is a test of error cause  test/FnCaster.ts:51   50:   function test_a(){                                    51:     throw new Error('test', { cause: 'test_cause' });   52:   }                                                    Error thrown in test:  Error {    message: 'test',  }  › test_a (file://test/FnCaster.ts:51:11)  › file://test/FnCaster.ts:53:3  ─

It would be nice for Ava to show the.cause in some form.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp