error-stack: possible serde implementation for Report
#793
Replies: 8 comments 12 replies
|
My idea would be twofold: The format I had in mind is: {
"messages": ["Printable A", "Printable B", "Root Error"],
"attachments": ["serde attachment 1", "serde attachment 2", "serde attachment 3"],
"sources": [
...
],
"backtrace": [
...
],
"spantrace": [
...
]
}This implementation would group frames to limit the indentation and level until a Backtrace and Spantrace would ideally be structured, but you are currently unable to extract the
|
|
It won't be possible to reconstruct a I currently see two ways to solve it. I think (a) is more approachable because it's easy to implement, to understand, and deeply nesting is probably not super common. Additionally, (b) is tricky to get the indices for the sources and it's hard to reconstruct the error later on. |
|
Example: where: (all the names are still tbd) @TimDiekmann a) {
"type": "message",
"content": "Printable A",
"sources": [
{
"type": "attachment",
"content": {
"serde": "A"
},
"sources": [
{
"type": "context",
"content": "Context C",
"sources": [
{
"type": "backtrace",
"frames": [],
"sources": [
{
"type": "spantrace",
"frames": [],
"sources": [
{
"type": "context",
"content": "Context F",
"sources": []
}
]
}
]
},
{
"type": "context",
"content": "Context F",
"sources": []
}
]
}
]
}
]
}@TimDiekmann b) [
{
"type": "message",
"content": "Printable A",
"parent": null,
"index": 0
},
{
"type": "attachment",
"content": {
"serde": "A"
},
"parent": 0,
"index": 1
}
](frames have been omitted) @indietyp a) {
"messages": [
"Printable A",
"Context C"
],
"attachments": [
{
"serde": "A"
}
],
"backtrace": [],
"spantrace": [],
"sources": [
{
"messages": [
"Context F"
],
"attachments": [],
"backtrace": [
{
"example": "frame"
}
],
"spantrace": [
{
"example": "frame"
}
]
},
{
"messages": [
"Context F"
],
"attachments": [],
"backtrace": [],
"spantrace": []
}
]
} |
|
I still think that |
|
I think I misinterpreted your approach. You are collecting a Maybe something like this? (replaced the messages with the letters for simplicity: {
"context": "C",
"attachments": [
"B",
"A"
],
"sources": [
{
"context": "H",
"attachments": [
"G",
"E"
],
"sources": []
},
{
"context": "F",
"attachments": [],
"sources": []
}
]
}NB: Please do not confuse |
|
Another hybrid approach which may makes sense: List all frames in a list until we encounter a split: {
"frames": [
{
"type": "attachment",
"letter": "A"
},
{
"type": "attachment",
"letter": "B"
},
{
"type": "context",
"letter": "C"
}
],
"sources": [
{
"frames": [
{
"type": "attachment",
"letter": "E"
},
{
"type": "attachment",
"letter": "G"
},
{
"type": "context",
"letter": "H"
}
],
"sources": []
},
{
"frames": [
{
"type": "context",
"letter": "F"
}
],
"sources": []
}
],
} |
|
I played around for a bit, and I think I found something. This is using more https://gist.github.com/indietyp/f092c56b267648b13cd95cab8835e8c3 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Pull Request:
#792#1290This is the discussion related to the serde implementation of error-stack
All reactions