replace graph Wrap and Stack with clues (#5018)
Now that graph errors are always transformed as part of the graph client wrapper or http_wrapper, we don't need to call graph.Stack or graph.Wrap outside of those inner helpers any longer. This PR swaps all those graph calls with equivalent clues funcs as a cleanup. Should not contain any logical changes. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #4685 #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
53a0525bfd
commit
e86592f51e
@ -153,6 +153,7 @@ func (suite *ItemCollectorUnitSuite) TestDrives() {
|
||||
{
|
||||
Values: nil,
|
||||
NextLink: nil,
|
||||
// needs graph.Stack, not clues.Stack
|
||||
Err: graph.Stack(ctx, mySiteURLNotFound),
|
||||
},
|
||||
},
|
||||
@ -165,6 +166,7 @@ func (suite *ItemCollectorUnitSuite) TestDrives() {
|
||||
{
|
||||
Values: nil,
|
||||
NextLink: nil,
|
||||
// needs graph.Stack, not clues.Stack
|
||||
Err: graph.Stack(ctx, mySiteNotFound),
|
||||
},
|
||||
},
|
||||
|
||||
@ -126,7 +126,7 @@ func (cfc *contactContainerCache) Populate(
|
||||
if err != nil {
|
||||
errs.AddRecoverable(
|
||||
ctx,
|
||||
graph.Stack(ctx, err).Label(fault.LabelForceNoBackupCreation))
|
||||
clues.StackWC(ctx, err).Label(fault.LabelForceNoBackupCreation))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ func restoreContact(
|
||||
) (*details.ExchangeInfo, error) {
|
||||
contact, err := api.BytesToContactable(body)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating contact from bytes")
|
||||
return nil, clues.WrapWC(ctx, err, "creating contact from bytes")
|
||||
}
|
||||
|
||||
ctx = clues.Add(ctx, "item_id", ptr.Val(contact.GetId()))
|
||||
@ -148,7 +148,7 @@ func restoreContact(
|
||||
|
||||
item, err := cr.PostItem(ctx, userID, destinationID, contact)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "restoring contact")
|
||||
return nil, clues.Wrap(err, "restoring contact")
|
||||
}
|
||||
|
||||
// contacts have no PUT request, and PATCH could retain data that's not
|
||||
@ -159,7 +159,7 @@ func restoreContact(
|
||||
if shouldDeleteOriginal {
|
||||
err := cr.DeleteItem(ctx, userID, collisionID)
|
||||
if err != nil && !errors.Is(err, core.ErrNotFound) {
|
||||
return nil, graph.Wrap(ctx, err, "deleting colliding contact")
|
||||
return nil, clues.Wrap(err, "deleting colliding contact")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -101,9 +101,8 @@ func (ecc *eventContainerCache) Populate(
|
||||
|
||||
err := ecc.addFolder(&cacheFolder)
|
||||
if err != nil {
|
||||
errs.AddRecoverable(
|
||||
ctx,
|
||||
graph.Stack(ctx, err).Label(fault.LabelForceNoBackupCreation))
|
||||
err := clues.StackWC(ctx, err).Label(fault.LabelForceNoBackupCreation)
|
||||
errs.AddRecoverable(ctx, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +158,7 @@ func restoreEvent(
|
||||
|
||||
item, err := er.PostItem(ctx, userID, destinationID, event)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "restoring event")
|
||||
return nil, clues.Wrap(err, "restoring event")
|
||||
}
|
||||
|
||||
// events have no PUT request, and PATCH could retain data that's not
|
||||
@ -169,7 +169,7 @@ func restoreEvent(
|
||||
if shouldDeleteOriginal {
|
||||
err := er.DeleteItem(ctx, userID, collisionID)
|
||||
if err != nil && !errors.Is(err, core.ErrNotFound) {
|
||||
return nil, graph.Wrap(ctx, err, "deleting colliding event")
|
||||
return nil, clues.Wrap(err, "deleting colliding event")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -128,9 +128,8 @@ func (mc *mailContainerCache) Populate(
|
||||
|
||||
err := mc.addFolder(&cacheFolder)
|
||||
if err != nil {
|
||||
errs.AddRecoverable(
|
||||
ctx,
|
||||
graph.Stack(ctx, err).Label(fault.LabelForceNoBackupCreation))
|
||||
err = clues.StackWC(ctx, err).Label(fault.LabelForceNoBackupCreation)
|
||||
errs.AddRecoverable(ctx, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -153,7 +153,7 @@ func restoreMail(
|
||||
|
||||
item, err := mr.PostItem(ctx, userID, destinationID, msg)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "restoring mail message")
|
||||
return nil, clues.Wrap(err, "restoring mail message")
|
||||
}
|
||||
|
||||
// mails have no PUT request, and PATCH could retain data that's not
|
||||
@ -164,7 +164,7 @@ func restoreMail(
|
||||
if shouldDeleteOriginal {
|
||||
err := mr.DeleteItem(ctx, userID, collisionID)
|
||||
if err != nil && !errors.Is(err, core.ErrNotFound) {
|
||||
return nil, graph.Wrap(ctx, err, "deleting colliding mail message")
|
||||
return nil, clues.Wrap(err, "deleting colliding mail message")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ func CollectLibraries(
|
||||
|
||||
odcs, canUsePreviousBackup, err := colls.Get(ctx, bpc.MetadataCollections, ssmb, errs)
|
||||
if err != nil {
|
||||
return nil, false, graph.Wrap(ctx, err, "getting library")
|
||||
return nil, false, clues.Wrap(err, "getting library")
|
||||
}
|
||||
|
||||
return append(collections, odcs...), canUsePreviousBackup, nil
|
||||
|
||||
@ -541,12 +541,12 @@ func serializeContent(
|
||||
|
||||
err := writer.WriteObjectValue("", obj)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "writing to serializer").Label(fault.LabelForceNoBackupCreation)
|
||||
return nil, clues.WrapWC(ctx, err, "writing to serializer").Label(fault.LabelForceNoBackupCreation)
|
||||
}
|
||||
|
||||
byteArray, err := writer.GetSerializedContent()
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting content from writer").Label(fault.LabelForceNoBackupCreation)
|
||||
return nil, clues.WrapWC(ctx, err, "getting content from writer").Label(fault.LabelForceNoBackupCreation)
|
||||
}
|
||||
|
||||
return byteArray, nil
|
||||
|
||||
@ -103,7 +103,6 @@ func restoreListItem(
|
||||
}
|
||||
|
||||
// Restore to List base to M365 back store
|
||||
|
||||
dii.SharePoint = api.ListToSPInfo(restoredList)
|
||||
|
||||
return dii, nil
|
||||
|
||||
@ -25,7 +25,6 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/dttm"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -67,7 +66,7 @@ func mustGetDefaultDriveID(
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
err = graph.Wrap(ctx, err, "retrieving drive")
|
||||
err = clues.Wrap(err, "retrieving drive")
|
||||
}
|
||||
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
@ -54,7 +54,7 @@ func GetMailboxInfo(
|
||||
// First check whether the user is able to access their inbox.
|
||||
inbox, err := gmb.GetMailInbox(ctx, userID)
|
||||
if err != nil {
|
||||
if err := api.EvaluateMailboxError(graph.Stack(ctx, err)); err != nil {
|
||||
if err := api.EvaluateMailboxError(clues.Stack(err)); err != nil {
|
||||
logger.CtxErr(ctx, err).Error("getting user's mail folder")
|
||||
|
||||
return mi, err
|
||||
@ -74,7 +74,7 @@ func GetMailboxInfo(
|
||||
logger.CtxErr(ctx, err).Info("err getting user's mailbox settings")
|
||||
|
||||
if !graph.IsErrAccessDenied(err) {
|
||||
return mi, graph.Wrap(ctx, err, "getting user's mailbox settings")
|
||||
return mi, clues.Wrap(err, "getting user's mailbox settings")
|
||||
}
|
||||
|
||||
logger.CtxErr(ctx, err).Info("mailbox settings access denied")
|
||||
|
||||
@ -70,7 +70,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
odErr := graphTD.ODataErrWithMsg(string(graph.ResourceNotFound), "message")
|
||||
|
||||
return mockGMB{
|
||||
mailboxErr: graph.Stack(ctx, odErr),
|
||||
mailboxErr: clues.Stack(odErr),
|
||||
}
|
||||
},
|
||||
expect: assert.False,
|
||||
@ -82,7 +82,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
odErr := graphTD.ODataErrWithMsg(string(graph.RequestResourceNotFound), "message")
|
||||
|
||||
return mockGMB{
|
||||
mailboxErr: graph.Stack(ctx, odErr),
|
||||
mailboxErr: clues.Stack(odErr),
|
||||
}
|
||||
},
|
||||
expect: assert.False,
|
||||
@ -95,7 +95,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
err := clues.Stack(core.ErrNotFound, odErr)
|
||||
|
||||
return mockGMB{
|
||||
mailboxErr: graph.Stack(ctx, err),
|
||||
mailboxErr: clues.StackWC(ctx, err),
|
||||
}
|
||||
},
|
||||
expect: assert.False,
|
||||
@ -107,7 +107,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
odErr := graphTD.ODataErrWithMsg("code", "message")
|
||||
|
||||
return mockGMB{
|
||||
mailboxErr: graph.Stack(ctx, odErr),
|
||||
mailboxErr: clues.Stack(odErr),
|
||||
}
|
||||
},
|
||||
expect: assert.False,
|
||||
@ -158,7 +158,7 @@ func (suite *EnabledUnitSuite) TestGetMailboxInfo() {
|
||||
err := graphTD.ODataErrWithMsg(string(graph.ResourceNotFound), "message")
|
||||
|
||||
return mockGMB{
|
||||
mailboxErr: graph.Stack(ctx, err),
|
||||
mailboxErr: clues.StackWC(ctx, err),
|
||||
}
|
||||
},
|
||||
expectErr: func(t *testing.T, err error) {
|
||||
@ -219,7 +219,7 @@ func (suite *EnabledUnitSuite) TestGetMailboxInfo() {
|
||||
return mockGMB{
|
||||
mailbox: models.NewMailFolder(),
|
||||
settings: mock.UserSettings(),
|
||||
inboxMessageErr: graph.Stack(ctx, err),
|
||||
inboxMessageErr: clues.StackWC(ctx, err),
|
||||
}
|
||||
},
|
||||
expectErr: func(t *testing.T, err error) {
|
||||
|
||||
@ -76,7 +76,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
name: "group not found",
|
||||
mock: func(ctx context.Context) api.GetByIDer[models.Groupable] {
|
||||
return mockGBI{
|
||||
err: graph.Stack(ctx, graphTD.ODataErrWithMsg(string(graph.RequestResourceNotFound), "message")),
|
||||
err: clues.StackWC(ctx, graphTD.ODataErrWithMsg(string(graph.RequestResourceNotFound), "message")),
|
||||
}
|
||||
},
|
||||
expect: assert.False,
|
||||
|
||||
@ -54,6 +54,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
name: "mysite not found",
|
||||
mock: func(ctx context.Context) getDefaultDriver {
|
||||
odErr := graphTD.ODataErrWithMsg("code", string(graph.MysiteNotFound))
|
||||
// needs graph.Stack, not clues.Stack
|
||||
return mockDGDD{nil, graph.Stack(ctx, odErr)}
|
||||
},
|
||||
expect: assert.False,
|
||||
@ -65,6 +66,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
name: "mysite URL not found",
|
||||
mock: func(ctx context.Context) getDefaultDriver {
|
||||
odErr := graphTD.ODataErrWithMsg("code", string(graph.MysiteURLNotFound))
|
||||
// needs graph.Stack, not clues.Stack
|
||||
return mockDGDD{nil, graph.Stack(ctx, odErr)}
|
||||
},
|
||||
expect: assert.False,
|
||||
@ -76,6 +78,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
name: "no sharepoint license",
|
||||
mock: func(ctx context.Context) getDefaultDriver {
|
||||
odErr := graphTD.ODataErrWithMsg("code", string(graph.NoSPLicense))
|
||||
// needs graph.Stack, not clues.Stack
|
||||
return mockDGDD{nil, graph.Stack(ctx, odErr)}
|
||||
},
|
||||
expect: assert.False,
|
||||
@ -87,7 +90,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
name: "user not found",
|
||||
mock: func(ctx context.Context) getDefaultDriver {
|
||||
odErr := graphTD.ODataErrWithMsg(string(graph.RequestResourceNotFound), "message")
|
||||
return mockDGDD{nil, graph.Stack(ctx, odErr)}
|
||||
return mockDGDD{nil, clues.StackWC(ctx, odErr)}
|
||||
},
|
||||
expect: assert.False,
|
||||
expectErr: func(t *testing.T, err error) {
|
||||
@ -98,7 +101,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
name: "resource locked",
|
||||
mock: func(ctx context.Context) getDefaultDriver {
|
||||
odErr := graphTD.ODataErrWithMsg(string(graph.NotAllowed), "resource")
|
||||
return mockDGDD{nil, graph.Stack(ctx, odErr)}
|
||||
return mockDGDD{nil, clues.StackWC(ctx, odErr)}
|
||||
},
|
||||
expect: assert.False,
|
||||
expectErr: func(t *testing.T, err error) {
|
||||
@ -109,7 +112,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
name: "arbitrary error",
|
||||
mock: func(ctx context.Context) getDefaultDriver {
|
||||
odErr := graphTD.ODataErrWithMsg("code", "message")
|
||||
return mockDGDD{nil, graph.Stack(ctx, odErr)}
|
||||
return mockDGDD{nil, clues.StackWC(ctx, odErr)}
|
||||
},
|
||||
expect: assert.False,
|
||||
expectErr: func(t *testing.T, err error) {
|
||||
|
||||
@ -13,7 +13,6 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/diagnostics"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
betamodels "github.com/alcionai/corso/src/pkg/services/m365/api/graph/betasdk/models"
|
||||
betasites "github.com/alcionai/corso/src/pkg/services/m365/api/graph/betasdk/sites"
|
||||
)
|
||||
@ -68,9 +67,13 @@ func GetSitePages(
|
||||
err error
|
||||
)
|
||||
|
||||
page, err = serv.Client().SitesById(siteID).PagesById(pageID).Get(ctx, opts)
|
||||
page, err = serv.
|
||||
Client().
|
||||
SitesById(siteID).
|
||||
PagesById(pageID).
|
||||
Get(ctx, opts)
|
||||
if err != nil {
|
||||
el.AddRecoverable(ctx, graph.Wrap(ctx, err, "fetching page"))
|
||||
el.AddRecoverable(ctx, clues.Wrap(err, "fetching page"))
|
||||
return
|
||||
}
|
||||
|
||||
@ -96,7 +99,7 @@ func FetchPages(ctx context.Context, bs *BetaService, siteID string) ([]NameID,
|
||||
for {
|
||||
resp, err = builder.Get(ctx, opts)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "fetching site page")
|
||||
return nil, clues.Wrap(err, "fetching site page")
|
||||
}
|
||||
|
||||
for _, entry := range resp.GetValue() {
|
||||
@ -146,9 +149,13 @@ func DeleteSitePage(
|
||||
serv *BetaService,
|
||||
siteID, pageID string,
|
||||
) error {
|
||||
err := serv.Client().SitesById(siteID).PagesById(pageID).Delete(ctx, nil)
|
||||
err := serv.
|
||||
Client().
|
||||
SitesById(siteID).
|
||||
PagesById(pageID).
|
||||
Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "deleting page")
|
||||
return clues.Wrap(err, "deleting page")
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -206,9 +213,13 @@ func RestoreSitePage(
|
||||
// 1. Create the Page on the site
|
||||
// 2. Publish the site
|
||||
// See: https://learn.microsoft.com/en-us/graph/api/sitepage-create?view=graph-rest-beta
|
||||
restoredPage, err := service.Client().SitesById(siteID).Pages().Post(ctx, page, nil)
|
||||
restoredPage, err := service.
|
||||
Client().
|
||||
SitesById(siteID).
|
||||
Pages().
|
||||
Post(ctx, page, nil)
|
||||
if err != nil {
|
||||
return dii, graph.Wrap(ctx, err, "creating page")
|
||||
return dii, clues.Wrap(err, "creating page")
|
||||
}
|
||||
|
||||
pageID = ptr.Val(restoredPage.GetId())
|
||||
@ -226,7 +237,7 @@ func RestoreSitePage(
|
||||
Publish().
|
||||
Post(ctx, nil)
|
||||
if err != nil {
|
||||
return dii, graph.Wrap(ctx, err, "publishing page")
|
||||
return dii, clues.Wrap(err, "publishing page")
|
||||
}
|
||||
|
||||
dii.SharePoint = PageInfo(restoredPage, int64(len(byteArray)))
|
||||
|
||||
@ -58,7 +58,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
name: "no sharepoint license",
|
||||
mock: func(ctx context.Context) getSiteRooter {
|
||||
odErr := graphTD.ODataErrWithMsg("code", string(graph.NoSPLicense))
|
||||
|
||||
// needs graph.Stack, not clues.StackWC
|
||||
return mockGSR{nil, graph.Stack(ctx, odErr)}
|
||||
},
|
||||
expect: assert.False,
|
||||
@ -70,8 +70,7 @@ func (suite *EnabledUnitSuite) TestIsServiceEnabled() {
|
||||
name: "arbitrary error",
|
||||
mock: func(ctx context.Context) getSiteRooter {
|
||||
odErr := graphTD.ODataErrWithMsg("code", "message")
|
||||
|
||||
return mockGSR{nil, graph.Stack(ctx, odErr)}
|
||||
return mockGSR{nil, clues.StackWC(ctx, odErr)}
|
||||
},
|
||||
expect: assert.False,
|
||||
expectErr: func(t *testing.T, err error) {
|
||||
|
||||
@ -31,7 +31,6 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/selectors"
|
||||
selTD "github.com/alcionai/corso/src/pkg/selectors/testdata"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
storeTD "github.com/alcionai/corso/src/pkg/storage/testdata"
|
||||
)
|
||||
|
||||
@ -166,7 +165,7 @@ func runOneDriveIncrementalBackupTests(
|
||||
) string {
|
||||
d, err := its.AC.Users().GetDefaultDrive(ctx, its.User.ID)
|
||||
if err != nil {
|
||||
err = graph.Wrap(ctx, err, "retrieving default user drive").
|
||||
err = clues.Wrap(err, "retrieving default user drive").
|
||||
With("user", its.User.ID)
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/selectors"
|
||||
selTD "github.com/alcionai/corso/src/pkg/selectors/testdata"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
storeTD "github.com/alcionai/corso/src/pkg/storage/testdata"
|
||||
)
|
||||
|
||||
@ -222,7 +221,7 @@ func runSharePointIncrementalBackupTests(
|
||||
) string {
|
||||
d, err := its.AC.Sites().GetDefaultDrive(ctx, its.Site.ID)
|
||||
if err != nil {
|
||||
err = graph.Wrap(ctx, err, "retrieving default site drive").
|
||||
err = clues.Wrap(err, "retrieving default site drive").
|
||||
With("site", its.Site.ID)
|
||||
}
|
||||
|
||||
@ -410,7 +409,7 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDelete
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Patch(ctx, patchBody, nil)
|
||||
require.NoError(t, err, clues.ToCore(graph.Stack(ctx, err)))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
var (
|
||||
mb = evmock.NewBus()
|
||||
@ -438,7 +437,7 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDelete
|
||||
ByDriveItemId(rootFolderID).
|
||||
Children().
|
||||
Get(ctx, nil)
|
||||
require.NoError(t, err, clues.ToCore(graph.Stack(ctx, err)))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
items := resp.GetValue()
|
||||
assert.Len(t, items, 2)
|
||||
@ -461,7 +460,7 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDelete
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Delete(ctx, nil)
|
||||
require.NoError(t, err, clues.ToCore(graph.Stack(ctx, err)))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
var (
|
||||
mb = evmock.NewBus()
|
||||
@ -515,7 +514,7 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDelete
|
||||
ByDriveItemId(rootFolderID).
|
||||
Children().
|
||||
Get(ctx, nil)
|
||||
require.NoError(t, err, clues.ToCore(graph.Stack(ctx, err)))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
items := resp.GetValue()
|
||||
assert.Len(t, items, 1)
|
||||
@ -558,7 +557,7 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDelete
|
||||
ByDriveItemId(rootFolderID).
|
||||
Children().
|
||||
Get(ctx, nil)
|
||||
require.NoError(t, err, clues.ToCore(graph.Stack(ctx, err)))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
items := resp.GetValue()
|
||||
assert.Len(t, items, 2)
|
||||
|
||||
@ -7,8 +7,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -51,7 +49,7 @@ func (c Access) GetToken(
|
||||
|
||||
resp, err := c.Post(ctx, rawURL, headers, body)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
return clues.Stack(err)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusBadRequest {
|
||||
|
||||
@ -15,7 +15,6 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/str"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -53,7 +52,7 @@ func (c Channels) GetChannel(
|
||||
ByChannelId(containerID).
|
||||
Get(ctx, config)
|
||||
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// GetChannelByName fetches a channel by name
|
||||
@ -77,7 +76,7 @@ func (c Channels) GetChannelByName(
|
||||
Channels().
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
return nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
gv := resp.GetValue()
|
||||
@ -117,12 +116,12 @@ func (c Channels) GetChannelMessage(
|
||||
ByChatMessageId(messageID).
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Stack(ctx, err)
|
||||
return nil, nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
replies, err := c.GetChannelMessageReplies(ctx, teamID, channelID, messageID)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Wrap(ctx, err, "retrieving message replies")
|
||||
return nil, nil, clues.Wrap(err, "retrieving message replies")
|
||||
}
|
||||
|
||||
message.SetReplies(replies)
|
||||
|
||||
@ -33,7 +33,7 @@ func (p *channelMessagePageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.ChatMessageable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *channelMessagePageCtrl) ValidModTimes() bool {
|
||||
@ -84,7 +84,7 @@ func (c Channels) GetChannelMessages(
|
||||
pager := c.NewChannelMessagePager(teamID, channelID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.ChatMessageable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -108,7 +108,7 @@ func (p *channelMessageDeltaPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.DeltaLinkValuer[models.ChatMessageable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *channelMessageDeltaPageCtrl) Reset(context.Context) {
|
||||
@ -220,7 +220,7 @@ func (p *channelMessageRepliesPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.ChatMessageable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *channelMessageRepliesPageCtrl) GetOdataNextLink() *string {
|
||||
@ -290,7 +290,7 @@ func (p *channelPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.Channelable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *channelPageCtrl) ValidModTimes() bool {
|
||||
|
||||
@ -52,11 +52,8 @@ func (c Contacts) CreateContainer(
|
||||
ByUserId(userID).
|
||||
ContactFolders().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating contact folder")
|
||||
}
|
||||
|
||||
return mdl, nil
|
||||
return mdl, clues.Wrap(err, "creating contact folder").OrNil()
|
||||
}
|
||||
|
||||
// DeleteContainer deletes the ContactFolder associated with the M365 ID if permissions are valid.
|
||||
@ -68,7 +65,7 @@ func (c Contacts) DeleteContainer(
|
||||
// https://github.com/alcionai/corso/issues/2707
|
||||
srv, err := NewService(c.Credentials, c.counter)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
return clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
err = srv.
|
||||
@ -78,11 +75,8 @@ func (c Contacts) DeleteContainer(
|
||||
ContactFolders().
|
||||
ByContactFolderId(containerID).
|
||||
Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (c Contacts) GetContainerByID(
|
||||
@ -102,11 +96,8 @@ func (c Contacts) GetContainerByID(
|
||||
ContactFolders().
|
||||
ByContactFolderId(containerID).
|
||||
Get(ctx, config)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// GetContainerByName fetches a folder by name
|
||||
@ -131,7 +122,7 @@ func (c Contacts) GetContainerByName(
|
||||
ContactFolders().
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
return nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
gv := resp.GetValue()
|
||||
@ -170,11 +161,8 @@ func (c Contacts) PatchFolder(
|
||||
ContactFolders().
|
||||
ByContactFolderId(containerID).
|
||||
Patch(ctx, body, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "patching contact folder")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "patching contact folder").OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -198,11 +186,8 @@ func (c Contacts) GetItem(
|
||||
Contacts().
|
||||
ByContactId(itemID).
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return cont, ContactInfo(cont), nil
|
||||
return cont, ContactInfo(cont), clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (c Contacts) PostItem(
|
||||
@ -218,11 +203,8 @@ func (c Contacts) PostItem(
|
||||
ByContactFolderId(containerID).
|
||||
Contacts().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating contact")
|
||||
}
|
||||
|
||||
return itm, nil
|
||||
return itm, clues.Wrap(err, "creating contact").OrNil()
|
||||
}
|
||||
|
||||
func (c Contacts) DeleteItem(
|
||||
@ -233,7 +215,7 @@ func (c Contacts) DeleteItem(
|
||||
// https://github.com/alcionai/corso/issues/2707
|
||||
srv, err := c.Service(c.counter)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
return clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
err = srv.
|
||||
@ -243,11 +225,8 @@ func (c Contacts) DeleteItem(
|
||||
Contacts().
|
||||
ByContactId(itemID).
|
||||
Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "deleting contact")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "deleting contact").OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -287,7 +266,7 @@ func (c Contacts) Serialize(
|
||||
) ([]byte, error) {
|
||||
contact, ok := item.(models.Contactable)
|
||||
if !ok {
|
||||
return nil, clues.New(fmt.Sprintf("item is not a Contactable: %T", item))
|
||||
return nil, clues.NewWC(ctx, fmt.Sprintf("item is not a Contactable: %T", item))
|
||||
}
|
||||
|
||||
ctx = clues.Add(ctx, "item_id", ptr.Val(contact.GetId()))
|
||||
@ -296,15 +275,12 @@ func (c Contacts) Serialize(
|
||||
defer writer.Close()
|
||||
|
||||
if err := writer.WriteObjectValue("", contact); err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
return nil, clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
bs, err := writer.GetSerializedContent()
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "serializing contact")
|
||||
}
|
||||
|
||||
return bs, nil
|
||||
return bs, clues.WrapWC(ctx, err, "serializing contact").OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@ -56,7 +56,7 @@ func (p *contactsFoldersPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.ContactFolderable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *contactsFoldersPageCtrl) SetNextLink(nextLink string) {
|
||||
@ -76,7 +76,7 @@ func (c Contacts) EnumerateContainers(
|
||||
userID,
|
||||
baseContainerID))
|
||||
|
||||
return containers, graph.Stack(ctx, err).OrNil()
|
||||
return containers, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -122,7 +122,7 @@ func (p *contactsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.Contactable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *contactsPageCtrl) SetNextLink(nextLink string) {
|
||||
@ -142,7 +142,7 @@ func (c Contacts) GetItemsInContainerByCollisionKey(
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "enumerating contacts")
|
||||
return nil, clues.Wrap(err, "enumerating contacts")
|
||||
}
|
||||
|
||||
m := map[string]string{}
|
||||
@ -163,7 +163,7 @@ func (c Contacts) GetItemIDsInContainer(
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "enumerating contacts")
|
||||
return nil, clues.Wrap(err, "enumerating contacts")
|
||||
}
|
||||
|
||||
m := map[string]struct{}{}
|
||||
@ -236,7 +236,7 @@ func (p *contactDeltaPager) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.DeltaLinkValuer[models.Contactable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *contactDeltaPager) SetNextLink(nextLink string) {
|
||||
|
||||
@ -15,7 +15,6 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/str"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -62,7 +61,7 @@ func (c Conversations) GetConversationPost(
|
||||
ByPostId(postID).
|
||||
Get(ctx, config)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Stack(ctx, err)
|
||||
return nil, nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
preview, contentLen, err := getConversationPostContentPreview(post)
|
||||
@ -96,7 +95,7 @@ func (c Conversations) GetConversationPost(
|
||||
|
||||
post.SetAttachments(attachments)
|
||||
|
||||
return post, conversationPostInfo(post, contentLen, preview), graph.Stack(ctx, err).OrNil()
|
||||
return post, conversationPostInfo(post, contentLen, preview), clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -181,7 +180,7 @@ func (c Conversations) getAttachments(
|
||||
ByPostId(postID).
|
||||
Get(ctx, cfg)
|
||||
if err != nil {
|
||||
return nil, 0, graph.Stack(ctx, err)
|
||||
return nil, 0, clues.Stack(err)
|
||||
}
|
||||
|
||||
attachments := post.GetAttachments()
|
||||
|
||||
@ -32,7 +32,7 @@ func (p *conversationsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.Conversationable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *conversationsPageCtrl) ValidModTimes() bool {
|
||||
@ -75,7 +75,7 @@ func (c Conversations) GetConversations(
|
||||
pager := c.NewConversationsPager(groupID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.Conversationable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -99,7 +99,7 @@ func (p *conversationThreadsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.ConversationThreadable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *conversationThreadsPageCtrl) ValidModTimes() bool {
|
||||
@ -150,7 +150,7 @@ func (c Conversations) GetConversationThreads(
|
||||
pager := c.NewConversationThreadsPager(groupID, conversationID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.ConversationThreadable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -174,7 +174,7 @@ func (p *conversationThreadPostsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.Postable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *conversationThreadPostsPageCtrl) ValidModTimes() bool {
|
||||
@ -228,7 +228,7 @@ func (c Conversations) GetConversationThreadPosts(
|
||||
pager := c.NewConversationThreadPostsPager(groupID, conversationID, threadID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.Postable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// GetConversations fetches all added and deleted conversation posts in the group.
|
||||
|
||||
@ -55,15 +55,15 @@ func (c Drives) GetFolderByName(
|
||||
foundItem, err := builder.Get(ctx, nil)
|
||||
if err != nil {
|
||||
if errors.Is(err, core.ErrNotFound) {
|
||||
return nil, graph.Stack(ctx, clues.Stack(ErrFolderNotFound, err))
|
||||
err = clues.Stack(ErrFolderNotFound, err)
|
||||
}
|
||||
|
||||
return nil, graph.Wrap(ctx, err, "getting folder")
|
||||
return nil, clues.Wrap(err, "getting folder")
|
||||
}
|
||||
|
||||
// Check if the item found is a folder, fail the call if not
|
||||
if foundItem.GetFolder() == nil {
|
||||
return nil, graph.Wrap(ctx, ErrFolderNotFound, "item is not a folder")
|
||||
return nil, clues.WrapWC(ctx, ErrFolderNotFound, "item is not a folder")
|
||||
}
|
||||
|
||||
return foundItem, nil
|
||||
@ -80,7 +80,7 @@ func (c Drives) GetRootFolder(
|
||||
Root().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting drive root")
|
||||
return nil, clues.Wrap(err, "getting drive root")
|
||||
}
|
||||
|
||||
return root, nil
|
||||
@ -100,7 +100,7 @@ func (c Drives) GetFolderChildren(
|
||||
Children().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting folder children")
|
||||
return nil, clues.Wrap(err, "getting folder children")
|
||||
}
|
||||
|
||||
return response.GetValue(), nil
|
||||
@ -129,11 +129,8 @@ func (c Drives) GetItem(
|
||||
Items().
|
||||
ByDriveItemId(itemID).
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting item")
|
||||
}
|
||||
|
||||
return di, nil
|
||||
return di, clues.Wrap(err, "getting item").OrNil()
|
||||
}
|
||||
|
||||
func (c Drives) NewItemContentUpload(
|
||||
@ -150,11 +147,8 @@ func (c Drives) NewItemContentUpload(
|
||||
ByDriveItemId(itemID).
|
||||
CreateUploadSession().
|
||||
Post(ctx, session, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "uploading drive item")
|
||||
}
|
||||
|
||||
return r, nil
|
||||
return r, clues.Wrap(err, "uploading drive item").OrNil()
|
||||
}
|
||||
|
||||
//nolint:lll
|
||||
@ -191,7 +185,7 @@ func (c Drives) PostItemInContainer(
|
||||
|
||||
newItem, err := builder.Post(ctx, newItem, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating item in folder")
|
||||
return nil, clues.Wrap(err, "creating item in folder")
|
||||
}
|
||||
|
||||
return newItem, nil
|
||||
@ -209,11 +203,8 @@ func (c Drives) PatchItem(
|
||||
Items().
|
||||
ByDriveItemId(itemID).
|
||||
Patch(ctx, item, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "patching drive item")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "patching drive item").OrNil()
|
||||
}
|
||||
|
||||
func (c Drives) PutItemContent(
|
||||
@ -229,11 +220,8 @@ func (c Drives) PutItemContent(
|
||||
ByDriveItemId(itemID).
|
||||
Content().
|
||||
Put(ctx, content, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "uploading drive item content")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "uploading drive item content").OrNil()
|
||||
}
|
||||
|
||||
// deletes require unique http clients
|
||||
@ -246,7 +234,7 @@ func (c Drives) DeleteItem(
|
||||
// https://github.com/alcionai/corso/issues/2707
|
||||
srv, err := c.Service(c.counter)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "creating adapter to delete item permission")
|
||||
return clues.WrapWC(ctx, err, "creating adapter to delete item permission")
|
||||
}
|
||||
|
||||
err = srv.
|
||||
@ -256,11 +244,8 @@ func (c Drives) DeleteItem(
|
||||
Items().
|
||||
ByDriveItemId(itemID).
|
||||
Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "deleting item").With("item_id", itemID)
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "deleting item").With("item_id", itemID).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -280,7 +265,7 @@ func (c Drives) GetItemPermission(
|
||||
Permissions().
|
||||
Get(ctx, nil)
|
||||
|
||||
return perm, graph.Wrap(ctx, err, "getting item permissions").OrNil()
|
||||
return perm, clues.Wrap(err, "getting item permissions").OrNil()
|
||||
}
|
||||
|
||||
func (c Drives) PostItemPermissionUpdate(
|
||||
@ -298,11 +283,8 @@ func (c Drives) PostItemPermissionUpdate(
|
||||
ByDriveItemId(itemID).
|
||||
Invite().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "posting permissions")
|
||||
}
|
||||
|
||||
return itm, nil
|
||||
return itm, clues.Wrap(err, "posting permissions").OrNil()
|
||||
}
|
||||
|
||||
func (c Drives) DeleteItemPermission(
|
||||
@ -313,7 +295,7 @@ func (c Drives) DeleteItemPermission(
|
||||
// https://github.com/alcionai/corso/issues/2707
|
||||
srv, err := c.Service(c.counter)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "creating adapter to delete item permission")
|
||||
return clues.WrapWC(ctx, err, "creating adapter to delete item permission")
|
||||
}
|
||||
|
||||
err = srv.
|
||||
@ -325,11 +307,8 @@ func (c Drives) DeleteItemPermission(
|
||||
Permissions().
|
||||
ByPermissionId(permissionID).
|
||||
Delete(graph.ConsumeNTokens(ctx, graph.PermissionsLC), nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "deleting drive item permission")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "deleting drive item permission").OrNil()
|
||||
}
|
||||
|
||||
func (c Drives) PostItemLinkShareUpdate(
|
||||
@ -346,11 +325,8 @@ func (c Drives) PostItemLinkShareUpdate(
|
||||
builder := drives.NewItemItemsItemCreateLinkRequestBuilder(rawURL, c.Stable.Adapter())
|
||||
|
||||
itm, err := builder.Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating link share")
|
||||
}
|
||||
|
||||
return itm, nil
|
||||
return itm, clues.Wrap(err, "creating link share").OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@ -62,7 +62,7 @@ func (p *driveItemPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.DriveItemable], error) {
|
||||
page, err := p.builder.Get(ctx, p.options)
|
||||
return page, graph.Stack(ctx, err).OrNil()
|
||||
return page, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *driveItemPageCtrl) SetNextLink(nextLink string) {
|
||||
@ -82,7 +82,7 @@ func (c Drives) GetItemsInContainerByCollisionKey(
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "enumerating drive items")
|
||||
return nil, clues.Wrap(err, "enumerating drive items")
|
||||
}
|
||||
|
||||
m := map[string]DriveItemIDType{}
|
||||
@ -106,7 +106,7 @@ func (c Drives) GetItemIDsInContainer(
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "enumerating contacts")
|
||||
return nil, clues.Wrap(err, "enumerating contacts")
|
||||
}
|
||||
|
||||
m := map[string]DriveItemIDType{}
|
||||
@ -182,7 +182,7 @@ func (p *DriveItemDeltaPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.DeltaLinkValuer[models.DriveItemable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *DriveItemDeltaPageCtrl) SetNextLink(link string) {
|
||||
@ -289,7 +289,7 @@ func (p *userDrivePager) GetPage(
|
||||
Drive().
|
||||
Get(ctx, nil)
|
||||
|
||||
return &nopUserDrivePage{drive: d}, graph.Stack(ctx, err).OrNil()
|
||||
return &nopUserDrivePage{drive: d}, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *userDrivePager) SetNextLink(link string) {
|
||||
@ -344,7 +344,7 @@ func (p *siteDrivePager) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.Driveable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *siteDrivePager) SetNextLink(link string) {
|
||||
@ -377,5 +377,5 @@ func GetAllDrives(
|
||||
return make([]models.Driveable, 0), nil
|
||||
}
|
||||
|
||||
return ds, graph.Stack(ctx, err).OrNil()
|
||||
return ds, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/control/testdata"
|
||||
"github.com/alcionai/corso/src/pkg/errs/core"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
)
|
||||
|
||||
type DriveAPIIntgSuite struct {
|
||||
@ -303,7 +302,7 @@ func (suite *DriveAPIIntgSuite) TestDrives_PostItemInContainer_replaceFolderRegr
|
||||
ByDriveItemId(ptr.Val(resultFolder.GetId())).
|
||||
Children().
|
||||
Get(ctx, nil)
|
||||
err = graph.Stack(ctx, err).OrNil()
|
||||
err = clues.Stack(err).OrNil()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
resultFiles := resultFileColl.GetValue()
|
||||
|
||||
@ -59,11 +59,8 @@ func (c Events) CreateContainer(
|
||||
ByUserId(userID).
|
||||
Calendars().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating calendar")
|
||||
}
|
||||
|
||||
return CalendarDisplayable{Calendarable: container}, nil
|
||||
return CalendarDisplayable{Calendarable: container}, clues.Wrap(err, "creating calendar").OrNil()
|
||||
}
|
||||
|
||||
// DeleteContainer removes a calendar from user's M365 account
|
||||
@ -76,7 +73,7 @@ func (c Events) DeleteContainer(
|
||||
// https://github.com/alcionai/corso/issues/2707
|
||||
srv, err := NewService(c.Credentials, c.counter)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
return clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
err = srv.Client().
|
||||
@ -85,11 +82,8 @@ func (c Events) DeleteContainer(
|
||||
Calendars().
|
||||
ByCalendarId(containerID).
|
||||
Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (c Events) GetContainerByID(
|
||||
@ -109,11 +103,8 @@ func (c Events) GetContainerByID(
|
||||
Calendars().
|
||||
ByCalendarId(containerID).
|
||||
Get(ctx, config)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return graph.CalendarDisplayable{Calendarable: resp}, nil
|
||||
return graph.CalendarDisplayable{Calendarable: resp}, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// GetContainerByName fetches a calendar by name
|
||||
@ -138,7 +129,7 @@ func (c Events) GetContainerByName(
|
||||
Calendars().
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
return nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
gv := resp.GetValue()
|
||||
@ -174,11 +165,8 @@ func (c Events) PatchCalendar(
|
||||
Calendars().
|
||||
ByCalendarId(containerID).
|
||||
Patch(ctx, body, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "patching event calendar")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "patching event calendar").OrNil()
|
||||
}
|
||||
|
||||
const (
|
||||
@ -217,7 +205,7 @@ func (c Events) GetItem(
|
||||
NewItemEventsEventItemRequestBuilder(rawURL, c.Stable.Adapter()).
|
||||
Get(ctx, config)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Stack(ctx, err)
|
||||
return nil, nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
_, err = GetCancelledEventDateStrings(event)
|
||||
@ -394,7 +382,7 @@ func (c Events) GetAttachments(
|
||||
Attachments().
|
||||
Get(ctx, config)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "event attachment download")
|
||||
return nil, clues.Wrap(err, "event attachment download")
|
||||
}
|
||||
|
||||
return attached.GetValue(), nil
|
||||
@ -438,7 +426,7 @@ func (c Events) GetItemInstances(
|
||||
Instances().
|
||||
Get(ctx, config)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
return nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
return events.GetValue(), nil
|
||||
@ -453,11 +441,8 @@ func (c Events) PostItem(
|
||||
builder := users.NewItemCalendarsItemEventsRequestBuilder(rawURL, c.Stable.Adapter())
|
||||
|
||||
itm, err := builder.Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating calendar event")
|
||||
}
|
||||
|
||||
return itm, nil
|
||||
return itm, clues.Wrap(err, "creating calendar event").OrNil()
|
||||
}
|
||||
|
||||
func (c Events) PatchItem(
|
||||
@ -469,11 +454,8 @@ func (c Events) PatchItem(
|
||||
builder := users.NewItemCalendarsItemEventsEventItemRequestBuilder(rawURL, c.Stable.Adapter())
|
||||
|
||||
itm, err := builder.Patch(ctx, body, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "updating calendar event")
|
||||
}
|
||||
|
||||
return itm, nil
|
||||
return itm, clues.Wrap(err, "updating calendar event").OrNil()
|
||||
}
|
||||
|
||||
func (c Events) DeleteItem(
|
||||
@ -484,7 +466,7 @@ func (c Events) DeleteItem(
|
||||
// https://github.com/alcionai/corso/issues/2707
|
||||
srv, err := c.Service(c.counter)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
return clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
err = srv.
|
||||
@ -494,11 +476,8 @@ func (c Events) DeleteItem(
|
||||
Events().
|
||||
ByEventId(itemID).
|
||||
Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "deleting calendar event")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "deleting calendar event").OrNil()
|
||||
}
|
||||
|
||||
func (c Events) PostSmallAttachment(
|
||||
@ -516,11 +495,8 @@ func (c Events) PostSmallAttachment(
|
||||
ByEventId(parentItemID).
|
||||
Attachments().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "uploading small event attachment")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "uploading small event attachment").OrNil()
|
||||
}
|
||||
|
||||
func (c Events) PostLargeAttachment(
|
||||
@ -544,7 +520,7 @@ func (c Events) PostLargeAttachment(
|
||||
CreateUploadSession().
|
||||
Post(ctx, session, nil)
|
||||
if err != nil {
|
||||
return "", graph.Wrap(ctx, err, "uploading large event attachment")
|
||||
return "", clues.Wrap(err, "uploading large event attachment")
|
||||
}
|
||||
|
||||
url := ptr.Val(us.GetUploadUrl())
|
||||
@ -605,15 +581,12 @@ func (c Events) Serialize(
|
||||
defer writer.Close()
|
||||
|
||||
if err := writer.WriteObjectValue("", event); err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
return nil, clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
bs, err := writer.GetSerializedContent()
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "serializing event")
|
||||
}
|
||||
|
||||
return bs, nil
|
||||
return bs, clues.WrapWC(ctx, err, "serializing event").OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@ -57,7 +57,7 @@ func (p *eventsCalendarsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.Calendarable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *eventsCalendarsPageCtrl) SetNextLink(nextLink string) {
|
||||
@ -74,7 +74,7 @@ func (c Events) EnumerateContainers(
|
||||
userID, _ string, // baseContainerID not needed here
|
||||
) ([]models.Calendarable, error) {
|
||||
containers, err := pagers.BatchEnumerateItems(ctx, c.NewEventCalendarsPager(userID))
|
||||
return containers, graph.Stack(ctx, err).OrNil()
|
||||
return containers, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -120,7 +120,7 @@ func (p *eventsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.Eventable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *eventsPageCtrl) SetNextLink(nextLink string) {
|
||||
@ -140,7 +140,7 @@ func (c Events) GetItemsInContainerByCollisionKey(
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "enumerating events")
|
||||
return nil, clues.Wrap(err, "enumerating events")
|
||||
}
|
||||
|
||||
m := map[string]string{}
|
||||
@ -161,7 +161,7 @@ func (c Events) GetItemIDsInContainer(
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "enumerating events")
|
||||
return nil, clues.Wrap(err, "enumerating events")
|
||||
}
|
||||
|
||||
m := map[string]struct{}{}
|
||||
@ -228,7 +228,7 @@ func (p *eventDeltaPager) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.DeltaLinkValuer[models.Eventable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *eventDeltaPager) SetNextLink(nextLink string) {
|
||||
|
||||
@ -297,6 +297,9 @@ func IsErrSharingDisabled(err error) bool {
|
||||
|
||||
// Wrap is a helper function that extracts ODataError metadata from
|
||||
// the error. If the error is not an ODataError type, returns the error.
|
||||
// You probably don't need this, because all calls to the graph client
|
||||
// automatically Stack these details. You probably want clues.Wrap.
|
||||
// This is primarily exported for test helpers.
|
||||
func Wrap(ctx context.Context, e error, msg string) *clues.Err {
|
||||
if e == nil {
|
||||
return nil
|
||||
@ -320,6 +323,9 @@ func Wrap(ctx context.Context, e error, msg string) *clues.Err {
|
||||
|
||||
// Stack is a helper function that extracts ODataError metadata from
|
||||
// the error. If the error is not an ODataError type, returns the error.
|
||||
// You probably don't need this, because all calls to the graph client
|
||||
// automatically Stack these details. You probably want clues.Stack.
|
||||
// This is primarily exported for test helpers.
|
||||
func Stack(ctx context.Context, e error) *clues.Err {
|
||||
return stackWithDepth(ctx, e, 1)
|
||||
}
|
||||
|
||||
@ -78,9 +78,11 @@ func getGroups(
|
||||
errs *fault.Bus,
|
||||
service graph.Servicer,
|
||||
) ([]models.Groupable, error) {
|
||||
resp, err := service.Client().Groups().Get(ctx, nil)
|
||||
resp, err := service.Client().
|
||||
Groups().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting all groups")
|
||||
return nil, clues.Wrap(err, "getting all groups")
|
||||
}
|
||||
|
||||
iter, err := msgraphgocore.NewPageIterator[models.Groupable](
|
||||
@ -88,7 +90,7 @@ func getGroups(
|
||||
service.Adapter(),
|
||||
models.CreateGroupCollectionResponseFromDiscriminatorValue)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating groups iterator")
|
||||
return nil, clues.WrapWC(ctx, err, "creating groups iterator")
|
||||
}
|
||||
|
||||
var (
|
||||
@ -103,7 +105,7 @@ func getGroups(
|
||||
|
||||
err := validateGroup(item)
|
||||
if err != nil {
|
||||
el.AddRecoverable(ctx, graph.Wrap(ctx, err, "validating groups"))
|
||||
el.AddRecoverable(ctx, clues.WrapWC(ctx, err, "validating groups"))
|
||||
} else {
|
||||
results = append(results, item)
|
||||
}
|
||||
@ -112,7 +114,7 @@ func getGroups(
|
||||
}
|
||||
|
||||
if err := iter.Iterate(ctx, iterator); err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "iterating all groups")
|
||||
return nil, clues.Wrap(err, "iterating all groups")
|
||||
}
|
||||
|
||||
return results, el.Failure()
|
||||
@ -132,12 +134,12 @@ func (c Groups) GetTeamByID(
|
||||
) (models.Teamable, error) {
|
||||
ctx = clues.Add(ctx, "resource_identifier", identifier)
|
||||
|
||||
t, err := c.Stable.Client().Teams().ByTeamId(identifier).Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "finding team by ID")
|
||||
}
|
||||
t, err := c.Stable.
|
||||
Client().
|
||||
Teams().
|
||||
ByTeamId(identifier).Get(ctx, nil)
|
||||
|
||||
return t, err
|
||||
return t, clues.Wrap(err, "finding team by ID").OrNil()
|
||||
}
|
||||
|
||||
// GetID can look up a group by either its canonical id (a uuid)
|
||||
@ -206,9 +208,12 @@ func (c Groups) GetByID(
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := c.Stable.Client().Groups().Get(ctx, opts)
|
||||
resp, err := c.Stable.
|
||||
Client().
|
||||
Groups().
|
||||
Get(ctx, opts)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "finding group by display name")
|
||||
return nil, clues.Wrap(err, "finding group by display name")
|
||||
}
|
||||
|
||||
return getGroupFromResponse(ctx, resp)
|
||||
@ -264,7 +269,7 @@ func (c Groups) GetAllSites(
|
||||
|
||||
service, err := c.Service(c.counter)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
return nil, clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
for _, ch := range channels {
|
||||
@ -325,7 +330,7 @@ func (c Groups) GetRootSite(
|
||||
) (models.Siteable, error) {
|
||||
service, err := c.Service(c.counter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
resp, err := service.
|
||||
@ -335,11 +340,8 @@ func (c Groups) GetRootSite(
|
||||
Sites().
|
||||
BySiteId("root").
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@ -14,7 +14,6 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/str"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
)
|
||||
|
||||
var ErrSkippableListTemplate = clues.New("unable to create lists with skippable templates")
|
||||
@ -65,7 +64,7 @@ func (c Lists) PostDrive(
|
||||
|
||||
newList, err := builder.Post(ctx, list, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating documentLibrary list")
|
||||
return nil, clues.Wrap(err, "creating documentLibrary list")
|
||||
}
|
||||
|
||||
// drive information is not returned by the list creation.
|
||||
@ -74,7 +73,7 @@ func (c Lists) PostDrive(
|
||||
Drive().
|
||||
Get(ctx, nil)
|
||||
|
||||
return drive, graph.Wrap(ctx, err, "fetching created documentLibrary").OrNil()
|
||||
return drive, clues.Wrap(err, "fetching created documentLibrary").OrNil()
|
||||
}
|
||||
|
||||
// SharePoint lists represent lists on a site. Inherits additional properties from
|
||||
@ -100,12 +99,12 @@ func (c Lists) GetListByID(ctx context.Context,
|
||||
ByListId(listID).
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Wrap(ctx, err, "fetching list")
|
||||
return nil, nil, clues.Wrap(err, "fetching list")
|
||||
}
|
||||
|
||||
cols, cTypes, lItems, err := c.getListContents(ctx, siteID, listID)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Wrap(ctx, err, "getting list contents")
|
||||
return nil, nil, clues.Wrap(err, "getting list contents")
|
||||
}
|
||||
|
||||
list.SetColumns(cols)
|
||||
@ -192,7 +191,7 @@ func (c Lists) PostList(
|
||||
Lists().
|
||||
Post(ctx, newList, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating list")
|
||||
return nil, clues.Wrap(err, "creating list")
|
||||
}
|
||||
|
||||
listItems := make([]models.ListItemable, 0)
|
||||
@ -208,7 +207,7 @@ func (c Lists) PostList(
|
||||
ptr.Val(restoredList.GetId()),
|
||||
listItems)
|
||||
if err != nil {
|
||||
err = graph.Wrap(ctx, err, "creating list item")
|
||||
err = clues.Wrap(err, "creating list item")
|
||||
el.AddRecoverable(ctx, err)
|
||||
}
|
||||
|
||||
@ -232,7 +231,7 @@ func (c Lists) PostListItems(
|
||||
Items().
|
||||
Post(ctx, lItem, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "creating item in list")
|
||||
return clues.Wrap(err, "creating item in list")
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,7 +250,7 @@ func (c Lists) DeleteList(
|
||||
ByListId(listID).
|
||||
Delete(ctx, nil)
|
||||
|
||||
return graph.Wrap(ctx, err, "deleting list").OrNil()
|
||||
return clues.Wrap(err, "deleting list").OrNil()
|
||||
}
|
||||
|
||||
func (c Lists) PatchList(
|
||||
@ -267,7 +266,7 @@ func (c Lists) PatchList(
|
||||
ByListId(listID).
|
||||
Patch(ctx, list, nil)
|
||||
|
||||
return patchedList, graph.Wrap(ctx, err, "patching list").OrNil()
|
||||
return patchedList, clues.Wrap(err, "patching list").OrNil()
|
||||
}
|
||||
|
||||
func BytesToListable(bytes []byte) (models.Listable, error) {
|
||||
|
||||
@ -33,7 +33,7 @@ func (p *listsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.Listable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *listsPageCtrl) ValidModTimes() bool {
|
||||
@ -76,7 +76,7 @@ func (c Lists) GetLists(
|
||||
pager := c.NewListsPager(siteID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.Listable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (c Lists) GetListsByCollisionKey(
|
||||
@ -121,7 +121,7 @@ func (p *listItemsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.ListItemable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *listItemsPageCtrl) ValidModTimes() bool {
|
||||
@ -169,7 +169,7 @@ func (c Lists) GetListItems(
|
||||
pager := c.NewListItemsPager(siteID, listID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.ListItemable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -194,7 +194,7 @@ func (p *columnsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.ColumnDefinitionable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *columnsPageCtrl) ValidModTimes() bool {
|
||||
@ -242,7 +242,7 @@ func (c Lists) GetListColumns(
|
||||
pager := c.NewColumnsPager(siteID, listID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.ColumnDefinitionable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -267,7 +267,7 @@ func (p *contentTypesPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.ContentTypeable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *contentTypesPageCtrl) ValidModTimes() bool {
|
||||
@ -315,7 +315,7 @@ func (c Lists) GetContentTypes(
|
||||
pager := c.NewContentTypesPager(siteID, listID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.ContentTypeable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -341,7 +341,7 @@ func (p *cTypesColumnsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.ColumnDefinitionable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *cTypesColumnsPageCtrl) ValidModTimes() bool {
|
||||
@ -394,7 +394,7 @@ func (c Lists) GetCTypesColumns(
|
||||
pager := c.NewCTypesColumnsPager(siteID, listID, contentTypeID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.ColumnDefinitionable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -420,7 +420,7 @@ func (p *columnLinksPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.ColumnLinkable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *columnLinksPageCtrl) ValidModTimes() bool {
|
||||
@ -473,5 +473,5 @@ func (c Lists) GetColumnLinks(
|
||||
pager := c.NewColumnLinksPager(siteID, listID, contentTypeID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.ColumnLinkable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
@ -61,11 +61,8 @@ func (c Mail) CreateContainer(
|
||||
ByMailFolderId(parentContainerID).
|
||||
ChildFolders().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating nested mail folder")
|
||||
}
|
||||
|
||||
return mdl, nil
|
||||
return mdl, clues.Wrap(err, "creating nested mail folder").OrNil()
|
||||
}
|
||||
|
||||
// DeleteContainer removes a mail folder with the corresponding M365 ID from the user's M365 Exchange account
|
||||
@ -78,7 +75,7 @@ func (c Mail) DeleteContainer(
|
||||
// https://github.com/alcionai/corso/issues/2707
|
||||
srv, err := NewService(c.Credentials, c.counter)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
return clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
err = srv.Client().
|
||||
@ -87,11 +84,8 @@ func (c Mail) DeleteContainer(
|
||||
MailFolders().
|
||||
ByMailFolderId(containerID).
|
||||
Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (c Mail) GetContainerByID(
|
||||
@ -111,11 +105,8 @@ func (c Mail) GetContainerByID(
|
||||
MailFolders().
|
||||
ByMailFolderId(containerID).
|
||||
Get(ctx, config)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// GetContainerByName fetches a folder by name
|
||||
@ -159,7 +150,7 @@ func (c Mail) GetContainerByName(
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
return nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
gv := resp.GetValue()
|
||||
@ -199,11 +190,8 @@ func (c Mail) MoveContainer(
|
||||
ByMailFolderId(containerID).
|
||||
Move().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "moving mail folder")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "moving mail folder").OrNil()
|
||||
}
|
||||
|
||||
func (c Mail) PatchFolder(
|
||||
@ -218,11 +206,8 @@ func (c Mail) PatchFolder(
|
||||
MailFolders().
|
||||
ByMailFolderId(containerID).
|
||||
Patch(ctx, body, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "patching mail folder")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "patching mail folder").OrNil()
|
||||
}
|
||||
|
||||
// TODO: needs pager implementation for completion
|
||||
@ -239,7 +224,7 @@ func (c Mail) GetContainerChildren(
|
||||
ChildFolders().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting container child folders")
|
||||
return nil, clues.Wrap(err, "getting container child folders")
|
||||
}
|
||||
|
||||
return resp.GetValue(), nil
|
||||
@ -273,7 +258,7 @@ func (c Mail) GetItem(
|
||||
ByMessageId(mailID).
|
||||
Get(ctx, config)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Stack(ctx, err)
|
||||
return nil, nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
mailBody = mail.GetBody()
|
||||
@ -340,7 +325,7 @@ func (c Mail) getAttachments(
|
||||
Attachments().
|
||||
Get(ctx, cfg)
|
||||
if err != nil {
|
||||
return nil, 0, graph.Stack(ctx, err)
|
||||
return nil, 0, clues.Stack(err)
|
||||
}
|
||||
|
||||
for _, a := range attachments.GetValue() {
|
||||
@ -382,7 +367,7 @@ func (c Mail) getAttachmentsIterated(
|
||||
Attachments().
|
||||
Get(ctx, cfg)
|
||||
if err != nil {
|
||||
return nil, 0, graph.Wrap(ctx, err, "getting mail attachment ids")
|
||||
return nil, 0, clues.Wrap(err, "getting mail attachment ids")
|
||||
}
|
||||
|
||||
for _, a := range attachments.GetValue() {
|
||||
@ -462,7 +447,7 @@ func (c Mail) getAttachmentByID(
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, graph.Wrap(ctx, err, "getting mail attachment by id")
|
||||
return nil, clues.Wrap(err, "getting mail attachment by id")
|
||||
}
|
||||
|
||||
return attachment, nil
|
||||
@ -482,7 +467,7 @@ func (c Mail) PostItem(
|
||||
Messages().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating mail message")
|
||||
return nil, clues.Wrap(err, "creating mail message")
|
||||
}
|
||||
|
||||
if itm == nil {
|
||||
@ -510,7 +495,7 @@ func (c Mail) MoveItem(
|
||||
Move().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return "", graph.Wrap(ctx, err, "moving message")
|
||||
return "", clues.Wrap(err, "moving message")
|
||||
}
|
||||
|
||||
return ptr.Val(resp.GetId()), nil
|
||||
@ -524,7 +509,7 @@ func (c Mail) DeleteItem(
|
||||
// https://github.com/alcionai/corso/issues/2707
|
||||
srv, err := NewService(c.Credentials, c.counter)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
return clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
err = srv.
|
||||
@ -534,11 +519,8 @@ func (c Mail) DeleteItem(
|
||||
Messages().
|
||||
ByMessageId(itemID).
|
||||
Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "deleting mail message")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "deleting mail message").OrNil()
|
||||
}
|
||||
|
||||
func (c Mail) PostSmallAttachment(
|
||||
@ -556,11 +538,8 @@ func (c Mail) PostSmallAttachment(
|
||||
ByMessageId(parentItemID).
|
||||
Attachments().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "uploading small mail attachment")
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Wrap(err, "uploading small mail attachment").OrNil()
|
||||
}
|
||||
|
||||
func (c Mail) PostLargeAttachment(
|
||||
@ -584,7 +563,7 @@ func (c Mail) PostLargeAttachment(
|
||||
CreateUploadSession().
|
||||
Post(ctx, session, nil)
|
||||
if err != nil {
|
||||
return "", graph.Wrap(ctx, err, "uploading large mail attachment")
|
||||
return "", clues.Wrap(err, "uploading large mail attachment")
|
||||
}
|
||||
|
||||
url := ptr.Val(us.GetUploadUrl())
|
||||
@ -645,15 +624,12 @@ func (c Mail) Serialize(
|
||||
defer writer.Close()
|
||||
|
||||
if err := writer.WriteObjectValue("", msg); err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
return nil, clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
bs, err := writer.GetSerializedContent()
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "serializing email")
|
||||
}
|
||||
|
||||
return bs, nil
|
||||
return bs, clues.WrapWC(ctx, err, "serializing email").OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@ -53,7 +53,7 @@ func (p *mailFoldersPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.MailFolderable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *mailFoldersPageCtrl) SetNextLink(nextLink string) {
|
||||
@ -70,7 +70,7 @@ func (c Mail) EnumerateContainers(
|
||||
userID, _ string, // baseContainerID not needed here
|
||||
) ([]models.MailFolderable, error) {
|
||||
containers, err := pagers.BatchEnumerateItems(ctx, c.NewMailFoldersPager(userID))
|
||||
return containers, graph.Stack(ctx, err).OrNil()
|
||||
return containers, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -116,7 +116,7 @@ func (p *mailsPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.Messageable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *mailsPageCtrl) SetNextLink(nextLink string) {
|
||||
@ -136,7 +136,7 @@ func (c Mail) GetItemsInContainerByCollisionKey(
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "enumerating mails")
|
||||
return nil, clues.Wrap(err, "enumerating mails")
|
||||
}
|
||||
|
||||
m := map[string]string{}
|
||||
@ -156,11 +156,8 @@ func (c Mail) GetItemsInContainer(
|
||||
pager := c.NewMailPager(userID, containerID)
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "enumerating mails")
|
||||
}
|
||||
|
||||
return items, nil
|
||||
return items, clues.Wrap(err, "enumerating mails").OrNil()
|
||||
}
|
||||
|
||||
func (c Mail) GetItemIDsInContainer(
|
||||
@ -172,7 +169,7 @@ func (c Mail) GetItemIDsInContainer(
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "enumerating mails")
|
||||
return nil, clues.Wrap(err, "enumerating mails")
|
||||
}
|
||||
|
||||
m := map[string]struct{}{}
|
||||
@ -245,7 +242,7 @@ func (p *mailDeltaPager) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.DeltaLinkValuer[models.Messageable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (p *mailDeltaPager) SetNextLink(nextLink string) {
|
||||
|
||||
@ -221,7 +221,7 @@ func EnumerateItems[T any](
|
||||
// get the next page of data, check for standard errors
|
||||
page, err := pager.GetPage(ctx)
|
||||
if err != nil {
|
||||
npr.err = graph.Stack(ctx, err)
|
||||
npr.err = clues.Stack(err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@ func batchWithMaxItemCount[T any](
|
||||
pageAdded, pageRemoved, err := getAddedAndRemoved(page, filters...)
|
||||
if err != nil {
|
||||
resultsPager.Cancel()
|
||||
return nil, nil, DeltaUpdate{}, graph.Stack(ctx, err)
|
||||
return nil, nil, DeltaUpdate{}, clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
removed = append(removed, pageRemoved...)
|
||||
@ -490,7 +490,7 @@ func batchWithMaxItemCount[T any](
|
||||
|
||||
du, err := resultsPager.Results()
|
||||
if err != nil {
|
||||
return nil, nil, DeltaUpdate{}, graph.Stack(ctx, err)
|
||||
return nil, nil, DeltaUpdate{}, clues.StackWC(ctx, err)
|
||||
}
|
||||
|
||||
// We processed all the results from the pager.
|
||||
@ -535,9 +535,9 @@ func GetAddedAndRemovedItemIDs[T any](
|
||||
return AddedAndRemoved{
|
||||
DU: DeltaUpdate{Reset: true},
|
||||
ValidModTimes: deltaPager.ValidModTimes(),
|
||||
}, graph.Stack(ctx, err)
|
||||
}, clues.Stack(err)
|
||||
} else if err == nil {
|
||||
return aar, graph.Stack(ctx, err).OrNil()
|
||||
return aar, clues.Stack(err).OrNil()
|
||||
}
|
||||
}
|
||||
|
||||
@ -560,7 +560,7 @@ func GetAddedAndRemovedItemIDs[T any](
|
||||
ValidModTimes: pager.ValidModTimes(),
|
||||
}
|
||||
|
||||
return aar, graph.Stack(ctx, err).OrNil()
|
||||
return aar, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
type getIDAndModDateTimer interface {
|
||||
|
||||
@ -14,7 +14,6 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -51,18 +50,18 @@ func (c Sites) GetRoot(
|
||||
Sites().
|
||||
BySiteId("root").
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting root site")
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
return resp, clues.Wrap(err, "getting root site").OrNil()
|
||||
}
|
||||
|
||||
// GetAll retrieves all sites.
|
||||
func (c Sites) GetAll(ctx context.Context, errs *fault.Bus) ([]models.Siteable, error) {
|
||||
resp, err := c.Stable.Client().Sites().Get(ctx, nil)
|
||||
resp, err := c.Stable.
|
||||
Client().
|
||||
Sites().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting all sites")
|
||||
return nil, clues.Wrap(err, "getting all sites")
|
||||
}
|
||||
|
||||
iter, err := msgraphgocore.NewPageIterator[models.Siteable](
|
||||
@ -70,7 +69,7 @@ func (c Sites) GetAll(ctx context.Context, errs *fault.Bus) ([]models.Siteable,
|
||||
c.Stable.Adapter(),
|
||||
models.CreateSiteCollectionResponseFromDiscriminatorValue)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating sites iterator")
|
||||
return nil, clues.WrapWC(ctx, err, "creating sites iterator")
|
||||
}
|
||||
|
||||
var (
|
||||
@ -85,7 +84,7 @@ func (c Sites) GetAll(ctx context.Context, errs *fault.Bus) ([]models.Siteable,
|
||||
|
||||
err := validateSite(item)
|
||||
if err != nil {
|
||||
el.AddRecoverable(ctx, graph.Wrap(ctx, err, "validating site"))
|
||||
el.AddRecoverable(ctx, clues.WrapWC(ctx, err, "validating site"))
|
||||
return true
|
||||
}
|
||||
|
||||
@ -99,7 +98,7 @@ func (c Sites) GetAll(ctx context.Context, errs *fault.Bus) ([]models.Siteable,
|
||||
}
|
||||
|
||||
if err := iter.Iterate(ctx, iterator); err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "enumerating sites")
|
||||
return nil, clues.Wrap(err, "enumerating sites")
|
||||
}
|
||||
|
||||
return us, el.Failure()
|
||||
@ -147,12 +146,8 @@ func (c Sites) GetByID(
|
||||
Sites().
|
||||
BySiteId(identifier).
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
err := graph.Wrap(ctx, err, "getting site by id")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, err
|
||||
return resp, clues.Wrap(err, "getting site by id").OrNil()
|
||||
}
|
||||
|
||||
// if the id is not a standard sharepoint ID, assume it's a url.
|
||||
@ -182,12 +177,8 @@ func (c Sites) GetByID(
|
||||
resp, err = sites.
|
||||
NewItemSitesSiteItemRequestBuilder(rawURL, c.Stable.Adapter()).
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
err := graph.Wrap(ctx, err, "getting site by weburl")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, err
|
||||
return resp, clues.Wrap(err, "getting site by weburl").OrNil()
|
||||
}
|
||||
|
||||
// GetIDAndName looks up the site matching the given ID, and returns
|
||||
@ -220,11 +211,8 @@ func (c Sites) GetDefaultDrive(
|
||||
BySiteId(site).
|
||||
Drive().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting site's default drive")
|
||||
}
|
||||
|
||||
return d, nil
|
||||
return d, clues.Wrap(err, "getting site's default drive").OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@ -34,7 +34,7 @@ func (p *chatMessagePageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.ChatMessageable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.StackWC(ctx, err).OrNil()
|
||||
}
|
||||
|
||||
func (p *chatMessagePageCtrl) ValidModTimes() bool {
|
||||
@ -82,7 +82,7 @@ func (c Chats) GetChatMessages(
|
||||
pager := c.NewChatMessagePager(chatID, cc)
|
||||
items, err := pagers.BatchEnumerateItems[models.ChatMessageable](ctx, pager)
|
||||
|
||||
return items, graph.Stack(ctx, err).OrNil()
|
||||
return items, clues.StackWC(ctx, err).OrNil()
|
||||
}
|
||||
|
||||
// GetChatMessageIDs fetches a delta of all messages in the chat.
|
||||
@ -125,7 +125,7 @@ func (p *chatPageCtrl) GetPage(
|
||||
ctx context.Context,
|
||||
) (pagers.NextLinkValuer[models.Chatable], error) {
|
||||
resp, err := p.builder.Get(ctx, p.options)
|
||||
return resp, graph.Stack(ctx, err).OrNil()
|
||||
return resp, clues.StackWC(ctx, err).OrNil()
|
||||
}
|
||||
|
||||
func (p *chatPageCtrl) ValidModTimes() bool {
|
||||
|
||||
@ -73,9 +73,12 @@ func (c Users) GetAll(
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := service.Client().Users().Get(ctx, config)
|
||||
resp, err := service.
|
||||
Client().
|
||||
Users().
|
||||
Get(ctx, config)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting all users")
|
||||
return nil, clues.Wrap(err, "getting all users")
|
||||
}
|
||||
|
||||
iter, err := msgraphgocore.NewPageIterator[models.Userable](
|
||||
@ -83,7 +86,7 @@ func (c Users) GetAll(
|
||||
service.Adapter(),
|
||||
models.CreateUserCollectionResponseFromDiscriminatorValue)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating users iterator")
|
||||
return nil, clues.WrapWC(ctx, err, "creating users iterator")
|
||||
}
|
||||
|
||||
var (
|
||||
@ -98,7 +101,7 @@ func (c Users) GetAll(
|
||||
|
||||
err := validateUser(item)
|
||||
if err != nil {
|
||||
el.AddRecoverable(ctx, graph.Wrap(ctx, err, "validating user"))
|
||||
el.AddRecoverable(ctx, clues.WrapWC(ctx, err, "validating user"))
|
||||
} else {
|
||||
us = append(us, item)
|
||||
}
|
||||
@ -107,7 +110,7 @@ func (c Users) GetAll(
|
||||
}
|
||||
|
||||
if err := iter.Iterate(ctx, iterator); err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "iterating all users")
|
||||
return nil, clues.Wrap(err, "iterating all users")
|
||||
}
|
||||
|
||||
return us, el.Failure()
|
||||
@ -136,11 +139,8 @@ func (c Users) GetByID(
|
||||
Users().
|
||||
ByUserId(identifier).
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return resp, err
|
||||
return resp, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// GetIDAndName looks up the user matching the given ID, and returns
|
||||
@ -228,11 +228,8 @@ func (c Users) GetMailboxSettings(
|
||||
fmt.Sprintf("https://graph.microsoft.com/v1.0/users/%s/mailboxSettings", userID),
|
||||
c.Stable.Adapter()).
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return settings, nil
|
||||
return settings, clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
func (c Users) GetMailInbox(
|
||||
@ -246,11 +243,8 @@ func (c Users) GetMailInbox(
|
||||
MailFolders().
|
||||
ByMailFolderId(MailInbox).
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting MailFolders")
|
||||
}
|
||||
|
||||
return inbox, nil
|
||||
return inbox, clues.Wrap(err, "getting MailFolders").OrNil()
|
||||
}
|
||||
|
||||
func (c Users) GetDefaultDrive(
|
||||
@ -263,11 +257,8 @@ func (c Users) GetDefaultDrive(
|
||||
ByUserId(userID).
|
||||
Drive().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting user's drive")
|
||||
}
|
||||
|
||||
return d, nil
|
||||
return d, clues.Wrap(err, "getting user's drive").OrNil()
|
||||
}
|
||||
|
||||
// TODO: This tries to determine if the user has hit their mailbox
|
||||
@ -295,11 +286,8 @@ func (c Users) GetFirstInboxMessage(
|
||||
Messages().
|
||||
Delta().
|
||||
Get(ctx, config)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return clues.Stack(err).OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@ -143,6 +143,7 @@ func (suite *siteUnitSuite) TestGetAllSites() {
|
||||
merr.SetMessage(ptr.To(string(graph.NoSPLicense)))
|
||||
odErr.SetErrorEscaped(merr)
|
||||
|
||||
// needs graph.Stack, not clues.Stack
|
||||
return mockGASites{nil, graph.Stack(ctx, odErr)}
|
||||
},
|
||||
expectErr: func(t *testing.T, err error) {
|
||||
@ -158,7 +159,7 @@ func (suite *siteUnitSuite) TestGetAllSites() {
|
||||
merr.SetMessage(ptr.To("message"))
|
||||
odErr.SetErrorEscaped(merr)
|
||||
|
||||
return mockGASites{nil, graph.Stack(ctx, odErr)}
|
||||
return mockGASites{nil, clues.StackWC(ctx, odErr)}
|
||||
},
|
||||
expectErr: func(t *testing.T, err error) {
|
||||
assert.Error(t, err, clues.ToCore(err))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user