Beef up Exchange export error handling (#4898)
Add log statements when errors are encountered so we get full clues output and make sure context clues are added to returned errors. The additional logging is necessary because not all corso SDK consumers will use clues which means they could miss out on valuable information if they just log the returned errors normally --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Test Plan - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
e46119a818
commit
1944c070cf
@ -54,7 +54,7 @@ func formatAddress(entry models.EmailAddressable) string {
|
||||
func FromJSON(ctx context.Context, body []byte) (string, error) {
|
||||
data, err := api.BytesToMessageable(body)
|
||||
if err != nil {
|
||||
return "", clues.Wrap(err, "converting to messageble")
|
||||
return "", clues.WrapWC(ctx, err, "converting to messageble")
|
||||
}
|
||||
|
||||
ctx = clues.Add(ctx, "item_id", ptr.Val(data.GetId()))
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/export"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
"github.com/alcionai/corso/src/pkg/metrics"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
)
|
||||
@ -51,6 +52,8 @@ func streamItems(
|
||||
id := item.ID()
|
||||
name := id + ".eml"
|
||||
|
||||
itemCtx := clues.Add(ictx, "stream_item_id", id)
|
||||
|
||||
stats.UpdateResourceCount(path.EmailCategory)
|
||||
|
||||
reader := item.ToReader()
|
||||
@ -59,19 +62,27 @@ func streamItems(
|
||||
reader.Close()
|
||||
|
||||
if err != nil {
|
||||
err = clues.WrapWC(itemCtx, err, "reading export item")
|
||||
|
||||
logger.CtxErr(ctx, err).Info("processing collection item")
|
||||
|
||||
ch <- export.Item{
|
||||
ID: id,
|
||||
Error: clues.Wrap(err, "reading data"),
|
||||
Error: err,
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
email, err := eml.FromJSON(ictx, content)
|
||||
email, err := eml.FromJSON(itemCtx, content)
|
||||
if err != nil {
|
||||
err = clues.Wrap(err, "converting JSON to eml")
|
||||
|
||||
logger.CtxErr(ctx, err).Info("processing collection item")
|
||||
|
||||
ch <- export.Item{
|
||||
ID: id,
|
||||
Error: clues.Wrap(err, "converting JSON to eml"),
|
||||
Error: err,
|
||||
}
|
||||
|
||||
continue
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user