|
6 | 6 | Err.ExpandErrorRecord.pq - start here, this is a lot simpler to use |
7 | 7 | Err.ExpandErrorRecord.Verbose.pq - when you want an excessive amount of details |
8 | 8 | */ |
9 | | - // when you want extra details on an exception, mainly for interactive use. |
| 9 | + |
10 | 10 | Err.ExpandErrorRecord = ( |
11 | 11 | exception as any, |
12 | 12 | optional options as nullable record |
13 | 13 | ) => [ |
14 | 14 | Json = (source as any) as text => Text.FromBinary( Json.FromValue( source ) ), |
| 15 | + // future: auto coerce exceptions and error records, so that either can be passed |
| 16 | + // isUncaught = (try exception)[HasError], |
| 17 | + // exception = |
| 18 | + // if not isUncaught |
| 19 | + // then exception |
| 20 | + // else try exception, |
| 21 | + |
| 22 | + // exception = try exception catch (e) => e, |
15 | 23 | return = [ |
16 | 24 | // Er_Type = Value.Type( exception ), // is alway a record? |
17 | | - Err = exception, |
| 25 | + Err = exception, |
18 | 26 | Err.Meta = Value.Metadata( Err ), |
19 | 27 | ErTypeMeta = Value.Metadata( Value.Type( Err ) ), |
20 | 28 | ErMeta_KeyNames = Text.Combine( Record.FieldNames( Err.Meta ), ", " ), |
21 | 29 |
|
22 | | - Reason = Err[Reason]? ?? null, |
23 | | - Message = Err[Message]? ?? null, |
24 | | - Detail = Err[Detail]? ?? null, |
25 | | - Message.Format = Err[Message.Format]? ?? null, |
26 | | - Message.Parameters = Err[Message.Parameters]? ?? null, |
| 30 | + Reason = Err[Reason]? ?? null, |
| 31 | + Message = Err[Message]? ?? null, |
| 32 | + Detail = Err[Detail]? ?? null, |
| 33 | + Message.Format = Err[Message.Format]? ?? null, |
| 34 | + Message.Parameters = Err[Message.Parameters]? ?? null, |
| 35 | + Message.Parameters_Json = |
| 36 | + Json( Message.Parameters ), |
| 37 | + |
27 | 38 |
|
28 | | - Expression.Stack = Err.Meta[Expression.Stack]? ?? null, |
29 | | - Expression.Stack.Json = Json( Expression.Stack ), |
30 | | - Expression.Stack.JsonLines = |
| 39 | + Expression.Stack = Err.Meta[Expression.Stack]? ?? null, |
| 40 | + Expression.Stack.Json = Json( Expression.Stack ), |
| 41 | + Expression.Stack.JsonLines = |
31 | 42 | Text.Combine( |
32 | 43 | List.Transform( |
33 | 44 | Expression.Stack, |
|
0 commit comments