mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-12 02:30:53 +09:00
Merge pull request #1474 from anyproto/go-3905-use-single-way-to-handle-errors
GO-3905: use single way to handle errors
This commit is contained in:
commit
dcb569bb5c
54 changed files with 345 additions and 380 deletions
|
@ -23,9 +23,9 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/core"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
|
||||
"github.com/anyproto/anytype-heart/space"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
"github.com/anyproto/anytype-heart/util/builtinobjects"
|
||||
"github.com/anyproto/anytype-heart/util/constant"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/pbtypes"
|
||||
)
|
||||
|
||||
|
@ -70,7 +70,7 @@ func (s *Service) RecoverFromLegacy(req *pb.RpcAccountRecoverFromLegacyExportReq
|
|||
|
||||
profile, err := getUserProfile(req)
|
||||
if err != nil {
|
||||
return RecoverFromLegacyResponse{}, oserror.TransformError(err)
|
||||
return RecoverFromLegacyResponse{}, anyerror.CleanupError(err)
|
||||
}
|
||||
|
||||
err = s.stop()
|
||||
|
@ -89,7 +89,7 @@ func (s *Service) RecoverFromLegacy(req *pb.RpcAccountRecoverFromLegacyExportReq
|
|||
s.rootPath = req.RootPath
|
||||
err = os.MkdirAll(s.rootPath, 0700)
|
||||
if err != nil {
|
||||
return RecoverFromLegacyResponse{}, oserror.TransformError(err)
|
||||
return RecoverFromLegacyResponse{}, anyerror.CleanupError(err)
|
||||
}
|
||||
if _, statErr := os.Stat(filepath.Join(s.rootPath, address)); os.IsNotExist(statErr) {
|
||||
if walletErr := core.WalletInitRepo(s.rootPath, res.Identity); walletErr != nil {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/core/anytype/config"
|
||||
"github.com/anyproto/anytype-heart/core/filestorage"
|
||||
"github.com/anyproto/anytype-heart/pb"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -49,13 +49,13 @@ func (s *Service) AccountMove(req *pb.RpcAccountMoveRequest) error {
|
|||
|
||||
if _, err := os.Stat(destination); !os.IsNotExist(err) { // if already exist (in case of the previous fail moving)
|
||||
if err := removeDirsRelativeToPath(destination, dirs); err != nil {
|
||||
return errors.Join(ErrFailedToRemoveAccountData, oserror.TransformError(err))
|
||||
return errors.Join(ErrFailedToRemoveAccountData, anyerror.CleanupError(err))
|
||||
}
|
||||
}
|
||||
|
||||
err := os.MkdirAll(destination, 0700)
|
||||
if err != nil {
|
||||
return errors.Join(ErrFailedToCreateLocalRepo, oserror.TransformError(err))
|
||||
return errors.Join(ErrFailedToCreateLocalRepo, anyerror.CleanupError(err))
|
||||
}
|
||||
|
||||
err = s.stop()
|
||||
|
@ -77,12 +77,12 @@ func (s *Service) AccountMove(req *pb.RpcAccountMoveRequest) error {
|
|||
}
|
||||
|
||||
if err := removeDirsRelativeToPath(srcPath, dirs); err != nil {
|
||||
return errors.Join(ErrFailedToRemoveAccountData, oserror.TransformError(err))
|
||||
return errors.Join(ErrFailedToRemoveAccountData, anyerror.CleanupError(err))
|
||||
}
|
||||
|
||||
if srcPath != conf.RepoPath { // remove root account dir, if move not from anytype source dir
|
||||
if err := os.RemoveAll(srcPath); err != nil {
|
||||
return errors.Join(ErrFailedToRemoveAccountData, oserror.TransformError(err))
|
||||
return errors.Join(ErrFailedToRemoveAccountData, anyerror.CleanupError(err))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/core/anytype/config"
|
||||
walletComp "github.com/anyproto/anytype-heart/core/wallet"
|
||||
"github.com/anyproto/anytype-heart/pb"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -42,7 +42,7 @@ func (s *Service) AccountStop(req *pb.RpcAccountStopRequest) error {
|
|||
if req.RemoveData {
|
||||
err := s.accountRemoveLocalData()
|
||||
if err != nil {
|
||||
return errors.Join(ErrFailedToRemoveAccountData, oserror.TransformError(err))
|
||||
return errors.Join(ErrFailedToRemoveAccountData, anyerror.CleanupError(err))
|
||||
}
|
||||
} else {
|
||||
err := s.stop()
|
||||
|
|
102
core/block.go
102
core/block.go
|
@ -27,7 +27,7 @@ func (mw *Middleware) BlockCreate(cctx context.Context, req *pb.RpcBlockCreateRe
|
|||
response := func(code pb.RpcBlockCreateResponseErrorCode, id string, err error) *pb.RpcBlockCreateResponse {
|
||||
m := &pb.RpcBlockCreateResponse{Error: &pb.RpcBlockCreateResponseError{Code: code}, BlockId: id}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ func (mw *Middleware) BlockLinkCreateWithObject(cctx context.Context, req *pb.Rp
|
|||
response := func(code pb.RpcBlockLinkCreateWithObjectResponseErrorCode, id, targetId string, objectDetails *types.Struct, err error) *pb.RpcBlockLinkCreateWithObjectResponse {
|
||||
m := &pb.RpcBlockLinkCreateWithObjectResponse{Error: &pb.RpcBlockLinkCreateWithObjectResponseError{Code: code}, BlockId: id, TargetId: targetId, Details: objectDetails}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func (mw *Middleware) ObjectOpen(cctx context.Context, req *pb.RpcObjectOpenRequ
|
|||
response := func(code pb.RpcObjectOpenResponseErrorCode, err error) *pb.RpcObjectOpenResponse {
|
||||
m := &pb.RpcObjectOpenResponse{Error: &pb.RpcObjectOpenResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.ObjectView = obj
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ func (mw *Middleware) ObjectShow(cctx context.Context, req *pb.RpcObjectShowRequ
|
|||
response := func(code pb.RpcObjectShowResponseErrorCode, err error) *pb.RpcObjectShowResponse {
|
||||
m := &pb.RpcObjectShowResponse{Error: &pb.RpcObjectShowResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.ObjectView = obj
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func (mw *Middleware) ObjectClose(cctx context.Context, req *pb.RpcObjectCloseRe
|
|||
response := func(code pb.RpcObjectCloseResponseErrorCode, err error) *pb.RpcObjectCloseResponse {
|
||||
m := &pb.RpcObjectCloseResponse{Error: &pb.RpcObjectCloseResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ func (mw *Middleware) BlockCopy(cctx context.Context, req *pb.RpcBlockCopyReques
|
|||
AnySlot: anySlot,
|
||||
}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ func (mw *Middleware) BlockPaste(cctx context.Context, req *pb.RpcBlockPasteRequ
|
|||
response := func(code pb.RpcBlockPasteResponseErrorCode, blockIds []string, caretPosition int32, isSameBlockCaret bool, err error) *pb.RpcBlockPasteResponse {
|
||||
m := &pb.RpcBlockPasteResponse{Error: &pb.RpcBlockPasteResponseError{Code: code}, BlockIds: blockIds, CaretPosition: caretPosition, IsSameBlockCaret: isSameBlockCaret}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ func (mw *Middleware) BlockCut(cctx context.Context, req *pb.RpcBlockCutRequest)
|
|||
AnySlot: anySlot,
|
||||
}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ func (mw *Middleware) BlockExport(cctx context.Context, req *pb.RpcBlockExportRe
|
|||
Path: path,
|
||||
}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ func (mw *Middleware) BlockSetCarriage(_ context.Context, req *pb.RpcBlockSetCar
|
|||
response := func(code pb.RpcBlockSetCarriageResponseErrorCode, err error) *pb.RpcBlockSetCarriageResponse {
|
||||
m := &pb.RpcBlockSetCarriageResponse{Error: &pb.RpcBlockSetCarriageResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ func (mw *Middleware) BlockUpload(cctx context.Context, req *pb.RpcBlockUploadRe
|
|||
response := func(code pb.RpcBlockUploadResponseErrorCode, err error) *pb.RpcBlockUploadResponse {
|
||||
m := &pb.RpcBlockUploadResponse{Error: &pb.RpcBlockUploadResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ func (mw *Middleware) BlockListDelete(cctx context.Context, req *pb.RpcBlockList
|
|||
response := func(code pb.RpcBlockListDeleteResponseErrorCode, err error) *pb.RpcBlockListDeleteResponse {
|
||||
m := &pb.RpcBlockListDeleteResponse{Error: &pb.RpcBlockListDeleteResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ func (mw *Middleware) BlockListDuplicate(cctx context.Context, req *pb.RpcBlockL
|
|||
response := func(ids []string, code pb.RpcBlockListDuplicateResponseErrorCode, err error) *pb.RpcBlockListDuplicateResponse {
|
||||
m := &pb.RpcBlockListDuplicateResponse{BlockIds: ids, Error: &pb.RpcBlockListDuplicateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ func (mw *Middleware) BlockSetFields(cctx context.Context, req *pb.RpcBlockSetFi
|
|||
response := func(code pb.RpcBlockSetFieldsResponseErrorCode, err error) *pb.RpcBlockSetFieldsResponse {
|
||||
m := &pb.RpcBlockSetFieldsResponse{Error: &pb.RpcBlockSetFieldsResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ func (mw *Middleware) BlockListSetFields(cctx context.Context, req *pb.RpcBlockL
|
|||
response := func(code pb.RpcBlockListSetFieldsResponseErrorCode, err error) *pb.RpcBlockListSetFieldsResponse {
|
||||
m := &pb.RpcBlockListSetFieldsResponse{Error: &pb.RpcBlockListSetFieldsResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ func (mw *Middleware) ObjectListDelete(cctx context.Context, req *pb.RpcObjectLi
|
|||
response := func(code pb.RpcObjectListDeleteResponseErrorCode, err error) *pb.RpcObjectListDeleteResponse {
|
||||
m := &pb.RpcObjectListDeleteResponse{Error: &pb.RpcObjectListDeleteResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ func (mw *Middleware) ObjectListSetIsArchived(cctx context.Context, req *pb.RpcO
|
|||
response := func(code pb.RpcObjectListSetIsArchivedResponseErrorCode, err error) *pb.RpcObjectListSetIsArchivedResponse {
|
||||
m := &pb.RpcObjectListSetIsArchivedResponse{Error: &pb.RpcObjectListSetIsArchivedResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ func (mw *Middleware) ObjectListSetIsFavorite(cctx context.Context, req *pb.RpcO
|
|||
response := func(code pb.RpcObjectListSetIsFavoriteResponseErrorCode, err error) *pb.RpcObjectListSetIsFavoriteResponse {
|
||||
m := &pb.RpcObjectListSetIsFavoriteResponse{Error: &pb.RpcObjectListSetIsFavoriteResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ func (mw *Middleware) BlockReplace(cctx context.Context, req *pb.RpcBlockReplace
|
|||
response := func(code pb.RpcBlockReplaceResponseErrorCode, blockId string, err error) *pb.RpcBlockReplaceResponse {
|
||||
m := &pb.RpcBlockReplaceResponse{Error: &pb.RpcBlockReplaceResponseError{Code: code}, BlockId: blockId}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -477,7 +477,7 @@ func (mw *Middleware) BlockTextSetColor(cctx context.Context, req *pb.RpcBlockTe
|
|||
response := func(code pb.RpcBlockTextSetColorResponseErrorCode, err error) *pb.RpcBlockTextSetColorResponse {
|
||||
m := &pb.RpcBlockTextSetColorResponse{Error: &pb.RpcBlockTextSetColorResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ func (mw *Middleware) BlockListSetBackgroundColor(cctx context.Context, req *pb.
|
|||
response := func(code pb.RpcBlockListSetBackgroundColorResponseErrorCode, err error) *pb.RpcBlockListSetBackgroundColorResponse {
|
||||
m := &pb.RpcBlockListSetBackgroundColorResponse{Error: &pb.RpcBlockListSetBackgroundColorResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ func (mw *Middleware) BlockLinkListSetAppearance(cctx context.Context, req *pb.R
|
|||
response := func(code pb.RpcBlockLinkListSetAppearanceResponseErrorCode, err error) *pb.RpcBlockLinkListSetAppearanceResponse {
|
||||
m := &pb.RpcBlockLinkListSetAppearanceResponse{Error: &pb.RpcBlockLinkListSetAppearanceResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ func (mw *Middleware) BlockListSetAlign(cctx context.Context, req *pb.RpcBlockLi
|
|||
response := func(code pb.RpcBlockListSetAlignResponseErrorCode, err error) *pb.RpcBlockListSetAlignResponse {
|
||||
m := &pb.RpcBlockListSetAlignResponse{Error: &pb.RpcBlockListSetAlignResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ func (mw *Middleware) BlockListSetVerticalAlign(cctx context.Context, req *pb.Rp
|
|||
response := func(code pb.RpcBlockListSetVerticalAlignResponseErrorCode, err error) *pb.RpcBlockListSetVerticalAlignResponse {
|
||||
m := &pb.RpcBlockListSetVerticalAlignResponse{Error: &pb.RpcBlockListSetVerticalAlignResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -577,7 +577,7 @@ func (mw *Middleware) BlockListMoveToExistingObject(cctx context.Context, req *p
|
|||
response := func(code pb.RpcBlockListMoveToExistingObjectResponseErrorCode, err error) *pb.RpcBlockListMoveToExistingObjectResponse {
|
||||
m := &pb.RpcBlockListMoveToExistingObjectResponse{Error: &pb.RpcBlockListMoveToExistingObjectResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ func (mw *Middleware) BlockListMoveToNewObject(cctx context.Context, req *pb.Rpc
|
|||
response := func(code pb.RpcBlockListMoveToNewObjectResponseErrorCode, linkId string, err error) *pb.RpcBlockListMoveToNewObjectResponse {
|
||||
m := &pb.RpcBlockListMoveToNewObjectResponse{Error: &pb.RpcBlockListMoveToNewObjectResponseError{Code: code}, LinkId: linkId}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -621,7 +621,7 @@ func (mw *Middleware) BlockListConvertToObjects(cctx context.Context, req *pb.Rp
|
|||
response := func(code pb.RpcBlockListConvertToObjectsResponseErrorCode, linkIds []string, err error) *pb.RpcBlockListConvertToObjectsResponse {
|
||||
m := &pb.RpcBlockListConvertToObjectsResponse{Error: &pb.RpcBlockListConvertToObjectsResponseError{Code: code}, LinkIds: linkIds}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ func (mw *Middleware) BlockTextListSetStyle(cctx context.Context, req *pb.RpcBlo
|
|||
response := func(code pb.RpcBlockTextListSetStyleResponseErrorCode, err error) *pb.RpcBlockTextListSetStyleResponse {
|
||||
m := &pb.RpcBlockTextListSetStyleResponse{Error: &pb.RpcBlockTextListSetStyleResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ func (mw *Middleware) BlockDivListSetStyle(cctx context.Context, req *pb.RpcBloc
|
|||
response := func(code pb.RpcBlockDivListSetStyleResponseErrorCode, err error) *pb.RpcBlockDivListSetStyleResponse {
|
||||
m := &pb.RpcBlockDivListSetStyleResponse{Error: &pb.RpcBlockDivListSetStyleResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ func (mw *Middleware) BlockTextListSetColor(cctx context.Context, req *pb.RpcBlo
|
|||
response := func(code pb.RpcBlockTextListSetColorResponseErrorCode, err error) *pb.RpcBlockTextListSetColorResponse {
|
||||
m := &pb.RpcBlockTextListSetColorResponse{Error: &pb.RpcBlockTextListSetColorResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ func (mw *Middleware) BlockTextListSetMark(cctx context.Context, req *pb.RpcBloc
|
|||
response := func(code pb.RpcBlockTextListSetMarkResponseErrorCode, err error) *pb.RpcBlockTextListSetMarkResponse {
|
||||
m := &pb.RpcBlockTextListSetMarkResponse{Error: &pb.RpcBlockTextListSetMarkResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ func (mw *Middleware) BlockTextListClearStyle(cctx context.Context, req *pb.RpcB
|
|||
response := func(code pb.RpcBlockTextListClearStyleResponseErrorCode, err error) *pb.RpcBlockTextListClearStyleResponse {
|
||||
m := &pb.RpcBlockTextListClearStyleResponse{Error: &pb.RpcBlockTextListClearStyleResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -768,7 +768,7 @@ func (mw *Middleware) BlockTextListClearContent(cctx context.Context, req *pb.Rp
|
|||
response := func(code pb.RpcBlockTextListClearContentResponseErrorCode, err error) *pb.RpcBlockTextListClearContentResponse {
|
||||
m := &pb.RpcBlockTextListClearContentResponse{Error: &pb.RpcBlockTextListClearContentResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -789,7 +789,7 @@ func (mw *Middleware) BlockTextSetText(cctx context.Context, req *pb.RpcBlockTex
|
|||
response := func(code pb.RpcBlockTextSetTextResponseErrorCode, err error) *pb.RpcBlockTextSetTextResponse {
|
||||
m := &pb.RpcBlockTextSetTextResponse{Error: &pb.RpcBlockTextSetTextResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ func (mw *Middleware) BlockLatexSetText(cctx context.Context, req *pb.RpcBlockLa
|
|||
response := func(code pb.RpcBlockLatexSetTextResponseErrorCode, err error) *pb.RpcBlockLatexSetTextResponse {
|
||||
m := &pb.RpcBlockLatexSetTextResponse{Error: &pb.RpcBlockLatexSetTextResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -829,7 +829,7 @@ func (mw *Middleware) BlockTextSetStyle(cctx context.Context, req *pb.RpcBlockTe
|
|||
response := func(code pb.RpcBlockTextSetStyleResponseErrorCode, err error) *pb.RpcBlockTextSetStyleResponse {
|
||||
m := &pb.RpcBlockTextSetStyleResponse{Error: &pb.RpcBlockTextSetStyleResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -849,7 +849,7 @@ func (mw *Middleware) BlockTextSetIcon(cctx context.Context, req *pb.RpcBlockTex
|
|||
response := func(code pb.RpcBlockTextSetIconResponseErrorCode, err error) *pb.RpcBlockTextSetIconResponse {
|
||||
m := &pb.RpcBlockTextSetIconResponse{Error: &pb.RpcBlockTextSetIconResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -869,7 +869,7 @@ func (mw *Middleware) BlockTextSetChecked(cctx context.Context, req *pb.RpcBlock
|
|||
response := func(code pb.RpcBlockTextSetCheckedResponseErrorCode, err error) *pb.RpcBlockTextSetCheckedResponse {
|
||||
m := &pb.RpcBlockTextSetCheckedResponse{Error: &pb.RpcBlockTextSetCheckedResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ func (mw *Middleware) BlockFileSetName(cctx context.Context, req *pb.RpcBlockFil
|
|||
response := func(code pb.RpcBlockFileSetNameResponseErrorCode, err error) *pb.RpcBlockFileSetNameResponse {
|
||||
m := &pb.RpcBlockFileSetNameResponse{Error: &pb.RpcBlockFileSetNameResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -921,7 +921,7 @@ func (mw *Middleware) BlockFileListSetStyle(cctx context.Context, req *pb.RpcBlo
|
|||
response := func(code pb.RpcBlockFileListSetStyleResponseErrorCode, err error) *pb.RpcBlockFileListSetStyleResponse {
|
||||
m := &pb.RpcBlockFileListSetStyleResponse{Error: &pb.RpcBlockFileListSetStyleResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -942,7 +942,7 @@ func (mw *Middleware) BlockImageSetName(cctx context.Context, req *pb.RpcBlockIm
|
|||
response := func(code pb.RpcBlockImageSetNameResponseErrorCode, err error) *pb.RpcBlockImageSetNameResponse {
|
||||
m := &pb.RpcBlockImageSetNameResponse{Error: &pb.RpcBlockImageSetNameResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -955,7 +955,7 @@ func (mw *Middleware) BlockVideoSetName(cctx context.Context, req *pb.RpcBlockVi
|
|||
response := func(code pb.RpcBlockVideoSetNameResponseErrorCode, err error) *pb.RpcBlockVideoSetNameResponse {
|
||||
m := &pb.RpcBlockVideoSetNameResponse{Error: &pb.RpcBlockVideoSetNameResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -969,7 +969,7 @@ func (mw *Middleware) BlockSplit(cctx context.Context, req *pb.RpcBlockSplitRequ
|
|||
response := func(blockId string, code pb.RpcBlockSplitResponseErrorCode, err error) *pb.RpcBlockSplitResponse {
|
||||
m := &pb.RpcBlockSplitResponse{BlockId: blockId, Error: &pb.RpcBlockSplitResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -991,7 +991,7 @@ func (mw *Middleware) BlockMerge(cctx context.Context, req *pb.RpcBlockMergeRequ
|
|||
response := func(code pb.RpcBlockMergeResponseErrorCode, err error) *pb.RpcBlockMergeResponse {
|
||||
m := &pb.RpcBlockMergeResponse{Error: &pb.RpcBlockMergeResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -1011,7 +1011,7 @@ func (mw *Middleware) BlockBookmarkFetch(cctx context.Context, req *pb.RpcBlockB
|
|||
response := func(code pb.RpcBlockBookmarkFetchResponseErrorCode, err error) *pb.RpcBlockBookmarkFetchResponse {
|
||||
m := &pb.RpcBlockBookmarkFetchResponse{Error: &pb.RpcBlockBookmarkFetchResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -1032,7 +1032,7 @@ func (mw *Middleware) BlockBookmarkCreateAndFetch(cctx context.Context, req *pb.
|
|||
response := func(code pb.RpcBlockBookmarkCreateAndFetchResponseErrorCode, id string, err error) *pb.RpcBlockBookmarkCreateAndFetchResponse {
|
||||
m := &pb.RpcBlockBookmarkCreateAndFetchResponse{Error: &pb.RpcBlockBookmarkCreateAndFetchResponseError{Code: code}, BlockId: id}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -1055,7 +1055,7 @@ func (mw *Middleware) BlockFileCreateAndUpload(cctx context.Context, req *pb.Rpc
|
|||
response := func(code pb.RpcBlockFileCreateAndUploadResponseErrorCode, id string, err error) *pb.RpcBlockFileCreateAndUploadResponse {
|
||||
m := &pb.RpcBlockFileCreateAndUploadResponse{Error: &pb.RpcBlockFileCreateAndUploadResponseError{Code: code}, BlockId: id}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -1077,7 +1077,7 @@ func (mw *Middleware) BlockRelationSetKey(cctx context.Context, req *pb.RpcBlock
|
|||
response := func(code pb.RpcBlockRelationSetKeyResponseErrorCode, err error) *pb.RpcBlockRelationSetKeyResponse {
|
||||
m := &pb.RpcBlockRelationSetKeyResponse{Error: &pb.RpcBlockRelationSetKeyResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -1098,7 +1098,7 @@ func (mw *Middleware) BlockRelationAdd(cctx context.Context, req *pb.RpcBlockRel
|
|||
response := func(code pb.RpcBlockRelationAddResponseErrorCode, err error) *pb.RpcBlockRelationAddResponse {
|
||||
m := &pb.RpcBlockRelationAddResponse{Error: &pb.RpcBlockRelationAddResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -1119,7 +1119,7 @@ func (mw *Middleware) BlockListTurnInto(cctx context.Context, req *pb.RpcBlockLi
|
|||
response := func(code pb.RpcBlockListTurnIntoResponseErrorCode, err error) *pb.RpcBlockListTurnIntoResponse {
|
||||
m := &pb.RpcBlockListTurnIntoResponse{Error: &pb.RpcBlockListTurnIntoResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -1138,7 +1138,7 @@ func (mw *Middleware) BlockPreview(cctx context.Context, req *pb.RpcBlockPreview
|
|||
response := func(code pb.RpcBlockPreviewResponseErrorCode, blocks []*model.Block, err error) *pb.RpcBlockPreviewResponse {
|
||||
m := &pb.RpcBlockPreviewResponse{Error: &pb.RpcBlockPreviewResponseError{Code: code}, Blocks: blocks}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/logging"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
"github.com/anyproto/anytype-heart/util/pbtypes"
|
||||
)
|
||||
|
||||
|
@ -396,7 +396,7 @@ func (dp *dropFilesProcess) Init(paths []string) (err error) {
|
|||
entry := &dropFileEntry{path: path, name: filepath.Base(path)}
|
||||
ok, e := dp.readdir(entry, true)
|
||||
if e != nil {
|
||||
return oserror.TransformError(err)
|
||||
return anyerror.CleanupError(err)
|
||||
}
|
||||
if ok {
|
||||
dp.root.child = append(dp.root.child, entry)
|
||||
|
|
|
@ -46,8 +46,8 @@ import (
|
|||
"github.com/anyproto/anytype-heart/space"
|
||||
"github.com/anyproto/anytype-heart/space/clientspace"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore/typeprovider"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
"github.com/anyproto/anytype-heart/util/constant"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/pbtypes"
|
||||
"github.com/anyproto/anytype-heart/util/text"
|
||||
)
|
||||
|
@ -121,12 +121,12 @@ func (e *export) Export(ctx context.Context, req pb.RpcObjectListExportRequest)
|
|||
var wr writer
|
||||
if req.Zip {
|
||||
if wr, err = newZipWriter(req.Path, tempFileName); err != nil {
|
||||
err = oserror.TransformError(err)
|
||||
err = anyerror.CleanupError(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if wr, err = newDirWriter(req.Path, req.IncludeFiles); err != nil {
|
||||
err = oserror.TransformError(err)
|
||||
err = anyerror.CleanupError(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
type writer interface {
|
||||
|
@ -73,7 +73,7 @@ func (d *dirWriter) WriteFile(filename string, r io.Reader, lastModifiedDate int
|
|||
lastModifiedDateUnix := time.Unix(lastModifiedDate, 0)
|
||||
err = os.Chtimes(filename, time.Now(), lastModifiedDateUnix)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to set date modified of export file: %w", oserror.TransformError(err))
|
||||
return fmt.Errorf("failed to set date modified of export file: %w", anyerror.CleanupError(err))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/core/block/process"
|
||||
"github.com/anyproto/anytype-heart/core/files"
|
||||
"github.com/anyproto/anytype-heart/pb"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
// TODO Move residual file methods here
|
||||
|
@ -24,7 +24,7 @@ func (s *Service) DownloadFile(ctx context.Context, req *pb.RpcFileDownloadReque
|
|||
|
||||
err := os.MkdirAll(req.Path, 0755)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("mkdir -p: %w", oserror.TransformError(err))
|
||||
return "", fmt.Errorf("mkdir -p: %w", anyerror.CleanupError(err))
|
||||
}
|
||||
progress := process.NewProgress(pb.ModelProcess_SaveFile)
|
||||
defer progress.Finish(nil)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/anyproto/anytype-heart/core/block/import/common/source"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/core"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
func ProvideFileName(fileName string, filesSource source.Source, path string, tempDirProvider core.TempDirProvider) (string, bool, error) {
|
||||
|
@ -47,7 +47,7 @@ func extractFileFromArchiveToTempDirectory(fileName string, rc io.ReadCloser, te
|
|||
if directoryWithFile != "" {
|
||||
directoryWithFile = filepath.Join(tempDir, directoryWithFile)
|
||||
if err := os.MkdirAll(directoryWithFile, 0777); err != nil && !os.IsExist(err) {
|
||||
return "", oserror.TransformError(err)
|
||||
return "", anyerror.CleanupError(err)
|
||||
}
|
||||
}
|
||||
pathToTmpFile := filepath.Join(tempDir, fileName)
|
||||
|
@ -56,7 +56,7 @@ func extractFileFromArchiveToTempDirectory(fileName string, rc io.ReadCloser, te
|
|||
return pathToTmpFile, nil
|
||||
}
|
||||
if err != nil {
|
||||
return "", oserror.TransformError(err)
|
||||
return "", anyerror.CleanupError(err)
|
||||
}
|
||||
defer tmpFile.Close()
|
||||
w := bufio.NewWriter(tmpFile)
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/logging"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
var log = logging.Logger("import")
|
||||
|
@ -16,7 +16,7 @@ var log = logging.Logger("import")
|
|||
func ExtractFileTimes(fileName string) (int64, int64) {
|
||||
fileInfo, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
log.Warnf("failed to get file info from path: %s", oserror.TransformError(err))
|
||||
log.Warnf("failed to get file info from path: %s", anyerror.CleanupError(err))
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/logging"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
var log = logging.Logger("import")
|
||||
|
@ -16,7 +16,7 @@ var log = logging.Logger("import")
|
|||
func ExtractFileTimes(fileName string) (int64, int64) {
|
||||
fileInfo, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
log.Warnf("failed to get file info from path: %s", oserror.TransformError(err))
|
||||
log.Warnf("failed to get file info from path: %s", anyerror.CleanupError(err))
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/logging"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
var log = logging.Logger("import")
|
||||
|
@ -16,7 +16,7 @@ var log = logging.Logger("import")
|
|||
func ExtractFileTimes(fileName string) (int64, int64) {
|
||||
fileInfo, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
log.Warnf("failed to get file info from path: %s", oserror.TransformError(err))
|
||||
log.Warnf("failed to get file info from path: %s", anyerror.CleanupError(err))
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/samber/lo"
|
||||
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
type Directory struct {
|
||||
|
@ -39,7 +39,7 @@ func (d *Directory) Iterate(callback func(fileName string, fileReader io.ReadClo
|
|||
for file := range d.fileReaders {
|
||||
fileReader, err := os.Open(file)
|
||||
if err != nil {
|
||||
return oserror.TransformError(err)
|
||||
return anyerror.CleanupError(err)
|
||||
}
|
||||
isContinue := callback(file, fileReader)
|
||||
fileReader.Close()
|
||||
|
@ -57,7 +57,7 @@ func (d *Directory) ProcessFile(fileName string, callback func(fileReader io.Rea
|
|||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return oserror.TransformError(err)
|
||||
return anyerror.CleanupError(err)
|
||||
}
|
||||
defer fileReader.Close()
|
||||
if err = callback(fileReader); err != nil {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/samber/lo"
|
||||
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
type File struct {
|
||||
|
@ -26,7 +26,7 @@ func (f *File) Initialize(importPath string) error {
|
|||
func (f *File) Iterate(callback func(fileName string, fileReader io.ReadCloser) bool) error {
|
||||
fileReader, err := os.Open(f.fileName)
|
||||
if err != nil {
|
||||
return oserror.TransformError(err)
|
||||
return anyerror.CleanupError(err)
|
||||
}
|
||||
defer fileReader.Close()
|
||||
callback(f.fileName, fileReader)
|
||||
|
@ -39,7 +39,7 @@ func (f *File) ProcessFile(fileName string, callback func(fileReader io.ReadClos
|
|||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return oserror.TransformError(err)
|
||||
return anyerror.CleanupError(err)
|
||||
}
|
||||
defer fileReader.Close()
|
||||
return callback(fileReader)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/samber/lo"
|
||||
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
type Zip struct {
|
||||
|
@ -50,7 +50,7 @@ func (z *Zip) Iterate(callback func(fileName string, fileReader io.ReadCloser) b
|
|||
for name, file := range z.fileReaders {
|
||||
fileReader, err := file.Open()
|
||||
if err != nil {
|
||||
return oserror.TransformError(err)
|
||||
return anyerror.CleanupError(err)
|
||||
}
|
||||
isContinue := callback(name, fileReader)
|
||||
fileReader.Close()
|
||||
|
@ -65,7 +65,7 @@ func (z *Zip) ProcessFile(fileName string, callback func(fileReader io.ReadClose
|
|||
if file, ok := z.fileReaders[fileName]; ok {
|
||||
fileReader, err := file.Open()
|
||||
if err != nil {
|
||||
return oserror.TransformError(err)
|
||||
return anyerror.CleanupError(err)
|
||||
}
|
||||
defer fileReader.Close()
|
||||
if err = callback(fileReader); err != nil {
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/core/files/fileobject"
|
||||
"github.com/anyproto/anytype-heart/pb"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
type FileSyncer struct {
|
||||
|
@ -72,10 +72,10 @@ func (s *FileSyncer) Sync(id domain.FullID, newIdsSet map[string]struct{}, b sim
|
|||
}
|
||||
_, err := s.service.UploadFileBlock(id.ObjectID, dto)
|
||||
if os.IsNotExist(err) {
|
||||
return oserror.TransformError(err)
|
||||
return anyerror.CleanupError(err)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %s", common.ErrFileLoad, oserror.TransformError(err).Error())
|
||||
return fmt.Errorf("%w: %s", common.ErrFileLoad, anyerror.CleanupError(err).Error())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pb"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/localstore/addr"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/logging"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
var log = logging.Logger("import")
|
||||
|
@ -98,7 +98,7 @@ func (s *IconSyncer) handleIconImage(spaceId string, newIdsSet map[string]struct
|
|||
}
|
||||
fileObjectId, _, err := s.service.UploadFile(context.Background(), spaceId, dto)
|
||||
if err != nil {
|
||||
return "", oserror.TransformError(err)
|
||||
return "", anyerror.CleanupError(err)
|
||||
}
|
||||
return fileObjectId, nil
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/core/smartblock"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/logging"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
const numberOfStages = 2 // 1 cycle to get snapshots and 1 cycle to create objects
|
||||
|
@ -166,7 +166,7 @@ func (h *HTML) getBlocksForSnapshot(rc io.ReadCloser, filesSource source.Source,
|
|||
if newFileName, _, err := common.ProvideFileName(block.GetFile().GetName(), filesSource, path, h.tempDirProvider); err == nil {
|
||||
block.GetFile().Name = newFileName
|
||||
} else {
|
||||
log.Errorf("failed to update file block with new file name: %v", oserror.TransformError(err))
|
||||
log.Errorf("failed to update file block with new file name: %v", anyerror.CleanupError(err))
|
||||
}
|
||||
}
|
||||
if block.GetText() != nil && block.GetText().Marks != nil && len(block.GetText().Marks.Marks) > 0 {
|
||||
|
@ -193,7 +193,7 @@ func (h *HTML) updateFilesInLinks(block *model.Block, filesSource source.Source,
|
|||
}
|
||||
continue
|
||||
}
|
||||
log.Errorf("failed to update link block with new file name: %v", oserror.TransformError(err))
|
||||
log.Errorf("failed to update link block with new file name: %v", anyerror.CleanupError(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ func (mw *Middleware) BlockDataviewRelationListAvailable(cctx context.Context, r
|
|||
response := func(code pb.RpcBlockDataviewRelationListAvailableResponseErrorCode, relations []*model.Relation, err error) *pb.RpcBlockDataviewRelationListAvailableResponse {
|
||||
m := &pb.RpcBlockDataviewRelationListAvailableResponse{Relations: relations, Error: &pb.RpcBlockDataviewRelationListAvailableResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func (mw *Middleware) BlockDataviewGroupOrderUpdate(cctx context.Context, req *p
|
|||
response := func(code pb.RpcBlockDataviewGroupOrderUpdateResponseErrorCode, err error) *pb.RpcBlockDataviewGroupOrderUpdateResponse {
|
||||
m := &pb.RpcBlockDataviewGroupOrderUpdateResponse{Error: &pb.RpcBlockDataviewGroupOrderUpdateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func (mw *Middleware) BlockDataviewObjectOrderUpdate(cctx context.Context, req *
|
|||
response := func(code pb.RpcBlockDataviewObjectOrderUpdateResponseErrorCode, err error) *pb.RpcBlockDataviewObjectOrderUpdateResponse {
|
||||
m := &pb.RpcBlockDataviewObjectOrderUpdateResponse{Error: &pb.RpcBlockDataviewObjectOrderUpdateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ func (mw *Middleware) BlockDataviewObjectOrderMove(cctx context.Context, req *pb
|
|||
response := func(code pb.RpcBlockDataviewObjectOrderMoveResponseErrorCode, err error) *pb.RpcBlockDataviewObjectOrderMoveResponse {
|
||||
m := &pb.RpcBlockDataviewObjectOrderMoveResponse{Error: &pb.RpcBlockDataviewObjectOrderMoveResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ func (mw *Middleware) BlockDataviewCreateFromExistingObject(cctx context.Context
|
|||
Error: &pb.RpcBlockDataviewCreateFromExistingObjectResponseError{Code: code},
|
||||
}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ func (mw *Middleware) BlockDataviewViewUpdate(cctx context.Context, req *pb.RpcB
|
|||
response := func(code pb.RpcBlockDataviewViewUpdateResponseErrorCode, err error) *pb.RpcBlockDataviewViewUpdateResponse {
|
||||
m := &pb.RpcBlockDataviewViewUpdateResponse{Error: &pb.RpcBlockDataviewViewUpdateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ func (mw *Middleware) BlockDataviewViewCreate(cctx context.Context, req *pb.RpcB
|
|||
response := func(viewId string, code pb.RpcBlockDataviewViewCreateResponseErrorCode, err error) *pb.RpcBlockDataviewViewCreateResponse {
|
||||
m := &pb.RpcBlockDataviewViewCreateResponse{ViewId: viewId, Error: &pb.RpcBlockDataviewViewCreateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ func (mw *Middleware) BlockDataviewViewDelete(cctx context.Context, req *pb.RpcB
|
|||
response := func(code pb.RpcBlockDataviewViewDeleteResponseErrorCode, err error) *pb.RpcBlockDataviewViewDeleteResponse {
|
||||
m := &pb.RpcBlockDataviewViewDeleteResponse{Error: &pb.RpcBlockDataviewViewDeleteResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ func (mw *Middleware) BlockDataviewViewSetActive(cctx context.Context, req *pb.R
|
|||
response := func(code pb.RpcBlockDataviewViewSetActiveResponseErrorCode, err error) *pb.RpcBlockDataviewViewSetActiveResponse {
|
||||
m := &pb.RpcBlockDataviewViewSetActiveResponse{Error: &pb.RpcBlockDataviewViewSetActiveResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ func (mw *Middleware) BlockDataviewViewSetPosition(cctx context.Context, req *pb
|
|||
response := func(code pb.RpcBlockDataviewViewSetPositionResponseErrorCode, err error) *pb.RpcBlockDataviewViewSetPositionResponse {
|
||||
m := &pb.RpcBlockDataviewViewSetPositionResponse{Error: &pb.RpcBlockDataviewViewSetPositionResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ func (mw *Middleware) BlockDataviewRelationAdd(cctx context.Context, req *pb.Rpc
|
|||
|
||||
m := &pb.RpcBlockDataviewRelationAddResponse{Error: &pb.RpcBlockDataviewRelationAddResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ func (mw *Middleware) BlockDataviewRelationDelete(cctx context.Context, req *pb.
|
|||
response := func(code pb.RpcBlockDataviewRelationDeleteResponseErrorCode, err error) *pb.RpcBlockDataviewRelationDeleteResponse {
|
||||
m := &pb.RpcBlockDataviewRelationDeleteResponse{Error: &pb.RpcBlockDataviewRelationDeleteResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ func (mw *Middleware) BlockDataviewSetSource(cctx context.Context, req *pb.RpcBl
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewSetSourceResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ func (mw *Middleware) BlockDataviewFilterAdd(cctx context.Context, req *pb.RpcBl
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewFilterAddResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ func (mw *Middleware) BlockDataviewFilterRemove(cctx context.Context, req *pb.Rp
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewFilterRemoveResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ func (mw *Middleware) BlockDataviewFilterReplace(cctx context.Context, req *pb.R
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewFilterReplaceResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ func (mw *Middleware) BlockDataviewFilterSort(cctx context.Context, req *pb.RpcB
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewFilterSortResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ func (mw *Middleware) BlockDataviewSortAdd(cctx context.Context, req *pb.RpcBloc
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewSortAddResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ func (mw *Middleware) BlockDataviewSortRemove(cctx context.Context, req *pb.RpcB
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewSortRemoveResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ func (mw *Middleware) BlockDataviewSortReplace(cctx context.Context, req *pb.Rpc
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewSortReplaceResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ func (mw *Middleware) BlockDataviewSortSort(cctx context.Context, req *pb.RpcBlo
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewSortSSortResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ func (mw *Middleware) BlockDataviewViewRelationAdd(cctx context.Context, req *pb
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewViewRelationAddResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ func (mw *Middleware) BlockDataviewViewRelationRemove(cctx context.Context, req
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewViewRelationRemoveResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ func (mw *Middleware) BlockDataviewViewRelationReplace(cctx context.Context, req
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewViewRelationReplaceResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -575,7 +575,7 @@ func (mw *Middleware) BlockDataviewViewRelationSort(cctx context.Context, req *p
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcBlockDataviewViewRelationSortResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
r.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ func (mw *Middleware) ObjectCollectionAdd(cctx context.Context, req *pb.RpcObjec
|
|||
response := func(code pb.RpcObjectCollectionAddResponseErrorCode, err error) *pb.RpcObjectCollectionAddResponse {
|
||||
m := &pb.RpcObjectCollectionAddResponse{Error: &pb.RpcObjectCollectionAddResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func (mw *Middleware) ObjectCollectionRemove(cctx context.Context, req *pb.RpcOb
|
|||
response := func(code pb.RpcObjectCollectionRemoveResponseErrorCode, err error) *pb.RpcObjectCollectionRemoveResponse {
|
||||
m := &pb.RpcObjectCollectionRemoveResponse{Error: &pb.RpcObjectCollectionRemoveResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ func (mw *Middleware) ObjectCollectionSort(cctx context.Context, req *pb.RpcObje
|
|||
response := func(code pb.RpcObjectCollectionSortResponseErrorCode, err error) *pb.RpcObjectCollectionSortResponse {
|
||||
m := &pb.RpcObjectCollectionSortResponse{Error: &pb.RpcObjectCollectionSortResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func (mw *Middleware) ObjectToCollection(_ context.Context, req *pb.RpcObjectToC
|
|||
}
|
||||
if err != nil {
|
||||
resp.Error.Code = pb.RpcObjectToCollectionResponseError_UNKNOWN_ERROR
|
||||
resp.Error.Description = err.Error()
|
||||
resp.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ func (mw *Middleware) ObjectCreate(cctx context.Context, req *pb.RpcObjectCreate
|
|||
response := func(code pb.RpcObjectCreateResponseErrorCode, id string, newDetails *types.Struct, err error) *pb.RpcObjectCreateResponse {
|
||||
m := &pb.RpcObjectCreateResponse{Error: &pb.RpcObjectCreateResponseError{Code: code}, Details: newDetails, ObjectId: id}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
m.Details = newDetails
|
||||
|
@ -45,7 +45,7 @@ func (mw *Middleware) ObjectCreateSet(cctx context.Context, req *pb.RpcObjectCre
|
|||
response := func(code pb.RpcObjectCreateSetResponseErrorCode, id string, newDetails *types.Struct, err error) *pb.RpcObjectCreateSetResponse {
|
||||
m := &pb.RpcObjectCreateSetResponse{Error: &pb.RpcObjectCreateSetResponseError{Code: code}, ObjectId: id}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
m.Details = newDetails
|
||||
|
@ -82,7 +82,7 @@ func (mw *Middleware) ObjectCreateBookmark(cctx context.Context, req *pb.RpcObje
|
|||
response := func(code pb.RpcObjectCreateBookmarkResponseErrorCode, id string, details *types.Struct, err error) *pb.RpcObjectCreateBookmarkResponse {
|
||||
m := &pb.RpcObjectCreateBookmarkResponse{Error: &pb.RpcObjectCreateBookmarkResponseError{Code: code}, ObjectId: id, Details: details}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ func (mw *Middleware) ObjectCreateObjectType(cctx context.Context, req *pb.RpcOb
|
|||
response := func(code pb.RpcObjectCreateObjectTypeResponseErrorCode, id string, details *types.Struct, err error) *pb.RpcObjectCreateObjectTypeResponse {
|
||||
m := &pb.RpcObjectCreateObjectTypeResponse{ObjectId: id, Details: details, Error: &pb.RpcObjectCreateObjectTypeResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ func (mw *Middleware) ObjectCreateRelation(cctx context.Context, req *pb.RpcObje
|
|||
return &pb.RpcObjectCreateRelationResponse{
|
||||
Error: &pb.RpcObjectCreateRelationResponseError{
|
||||
Code: pb.RpcObjectCreateRelationResponseError_UNKNOWN_ERROR,
|
||||
Description: err.Error(),
|
||||
Description: getErrorDescription(err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ func (mw *Middleware) ObjectCreateRelationOption(cctx context.Context, req *pb.R
|
|||
return &pb.RpcObjectCreateRelationOptionResponse{
|
||||
Error: &pb.RpcObjectCreateRelationOptionResponseError{
|
||||
Code: pb.RpcObjectCreateRelationOptionResponseError_UNKNOWN_ERROR,
|
||||
Description: err.Error(),
|
||||
Description: getErrorDescription(err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ func (mw *Middleware) ObjectCreateFromUrl(cctx context.Context, req *pb.RpcObjec
|
|||
response := func(code pb.RpcObjectCreateFromUrlResponseErrorCode, id string, err error, newDetails *types.Struct) *pb.RpcObjectCreateFromUrlResponse {
|
||||
m := &pb.RpcObjectCreateFromUrlResponse{Details: newDetails, Error: &pb.RpcObjectCreateFromUrlResponseError{Code: code}, ObjectId: id}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ func (mw *Middleware) DebugTree(cctx context.Context, req *pb.RpcDebugTreeReques
|
|||
}
|
||||
if err != nil {
|
||||
rpcErr.Code = pb.RpcDebugTreeResponseError_UNKNOWN_ERROR
|
||||
rpcErr.Description = err.Error()
|
||||
rpcErr.Description = getErrorDescription(err)
|
||||
}
|
||||
return &pb.RpcDebugTreeResponse{
|
||||
Error: rpcErr,
|
||||
|
@ -41,7 +41,7 @@ func (mw *Middleware) DebugTreeHeads(cctx context.Context, req *pb.RpcDebugTreeH
|
|||
}
|
||||
if err != nil {
|
||||
rpcErr.Code = pb.RpcDebugTreeHeadsResponseError_UNKNOWN_ERROR
|
||||
rpcErr.Description = err.Error()
|
||||
rpcErr.Description = getErrorDescription(err)
|
||||
}
|
||||
return &pb.RpcDebugTreeHeadsResponse{
|
||||
Error: rpcErr,
|
||||
|
@ -73,7 +73,7 @@ func (mw *Middleware) DebugSpaceSummary(cctx context.Context, req *pb.RpcDebugSp
|
|||
}
|
||||
if err != nil {
|
||||
rpcErr.Code = pb.RpcDebugSpaceSummaryResponseError_UNKNOWN_ERROR
|
||||
rpcErr.Description = err.Error()
|
||||
rpcErr.Description = getErrorDescription(err)
|
||||
}
|
||||
infos := make([]*pb.RpcDebugTreeInfo, 0, len(spaceSummary.TreeInfos))
|
||||
for _, i := range spaceSummary.TreeInfos {
|
||||
|
@ -125,7 +125,7 @@ func (mw *Middleware) DebugStackGoroutines(_ context.Context, req *pb.RpcDebugSt
|
|||
}
|
||||
if err != nil {
|
||||
res.Error.Code = pb.RpcDebugStackGoroutinesResponseError_UNKNOWN_ERROR
|
||||
res.Error.Description = err.Error()
|
||||
res.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ func (mw *Middleware) DebugExportLocalstore(cctx context.Context, req *pb.RpcDeb
|
|||
}
|
||||
if err != nil {
|
||||
res.Error.Code = pb.RpcDebugExportLocalstoreResponseError_UNKNOWN_ERROR
|
||||
res.Error.Description = err.Error()
|
||||
res.Error.Description = getErrorDescription(err)
|
||||
return
|
||||
} else {
|
||||
res.Path = path
|
||||
|
@ -171,7 +171,7 @@ func (mw *Middleware) DebugSubscriptions(_ context.Context, _ *pb.RpcDebugSubscr
|
|||
}
|
||||
if err != nil {
|
||||
res.Error.Code = pb.RpcDebugSubscriptionsResponseError_UNKNOWN_ERROR
|
||||
res.Error.Description = err.Error()
|
||||
res.Error.Description = getErrorDescription(err)
|
||||
return
|
||||
}
|
||||
res.Subscriptions = subscriptions
|
||||
|
@ -194,7 +194,7 @@ func (mw *Middleware) DebugOpenedObjects(_ context.Context, _ *pb.RpcDebugOpened
|
|||
}
|
||||
if err != nil {
|
||||
res.Error.Code = pb.RpcDebugOpenedObjectsResponseError_UNKNOWN_ERROR
|
||||
res.Error.Description = err.Error()
|
||||
res.Error.Description = getErrorDescription(err)
|
||||
return
|
||||
}
|
||||
res.ObjectIDs = objectIDs
|
||||
|
|
|
@ -13,7 +13,7 @@ func (mw *Middleware) DeviceNetworkStateSet(cctx context.Context, req *pb.RpcDev
|
|||
response := func(code pb.RpcDeviceNetworkStateSetResponseErrorCode, err error) *pb.RpcDeviceNetworkStateSetResponse {
|
||||
m := &pb.RpcDeviceNetworkStateSetResponse{Error: &pb.RpcDeviceNetworkStateSetResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ func (mw *Middleware) DeviceSetName(cctx context.Context, req *pb.RpcDeviceSetNa
|
|||
response := func(code pb.RpcDeviceSetNameResponseErrorCode, err error) *pb.RpcDeviceSetNameResponse {
|
||||
m := &pb.RpcDeviceSetNameResponse{Error: &pb.RpcDeviceSetNameResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ func (mw *Middleware) DeviceList(cctx context.Context, _ *pb.RpcDeviceListReques
|
|||
response := func(code pb.RpcDeviceListResponseErrorCode, devices []*model.DeviceInfo, err error) *pb.RpcDeviceListResponse {
|
||||
m := &pb.RpcDeviceListResponse{Error: &pb.RpcDeviceListResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
m.Devices = devices
|
||||
return m
|
||||
|
|
|
@ -17,7 +17,7 @@ func (mw *Middleware) ObjectListExport(cctx context.Context, req *pb.RpcObjectLi
|
|||
}
|
||||
if err != nil {
|
||||
res.Error.Code = pb.RpcObjectListExportResponseError_UNKNOWN_ERROR
|
||||
res.Error.Description = err.Error()
|
||||
res.Error.Description = getErrorDescription(err)
|
||||
return
|
||||
} else {
|
||||
res.Path = path
|
||||
|
|
|
@ -25,7 +25,7 @@ func (mw *Middleware) UnsplashSearch(cctx context.Context, req *pb.RpcUnsplashSe
|
|||
if strings.Contains(err.Error(), "Rate limit exhausted") {
|
||||
m.Error.Code = pb.RpcUnsplashSearchResponseError_RATE_LIMIT_EXCEEDED
|
||||
}
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func (mw *Middleware) UnsplashDownload(cctx context.Context, req *pb.RpcUnsplash
|
|||
if strings.Contains(err.Error(), "Rate limit exhausted") {
|
||||
m.Error.Code = pb.RpcUnsplashDownloadResponseError_RATE_LIMIT_EXCEEDED
|
||||
}
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ func (mw *Middleware) GalleryDownloadManifest(_ context.Context, req *pb.RpcGall
|
|||
}
|
||||
if err != nil {
|
||||
m.Error.Code = pb.RpcGalleryDownloadManifestResponseError_UNKNOWN_ERROR
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
|
14
core/file.go
14
core/file.go
|
@ -18,7 +18,7 @@ func (mw *Middleware) FileDownload(cctx context.Context, req *pb.RpcFileDownload
|
|||
response := func(path string, code pb.RpcFileDownloadResponseErrorCode, err error) *pb.RpcFileDownloadResponse {
|
||||
m := &pb.RpcFileDownloadResponse{Error: &pb.RpcFileDownloadResponseError{Code: code}, LocalPath: path}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func (mw *Middleware) FileDrop(cctx context.Context, req *pb.RpcFileDropRequest)
|
|||
response := func(code pb.RpcFileDropResponseErrorCode, err error) *pb.RpcFileDropResponse {
|
||||
m := &pb.RpcFileDropResponse{Error: &pb.RpcFileDropResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ func (mw *Middleware) FileOffload(cctx context.Context, req *pb.RpcFileOffloadRe
|
|||
response := func(bytesOffloaded uint64, code pb.RpcFileOffloadResponseErrorCode, err error) *pb.RpcFileOffloadResponse {
|
||||
m := &pb.RpcFileOffloadResponse{BytesOffloaded: bytesOffloaded, Error: &pb.RpcFileOffloadResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -100,7 +100,7 @@ func (mw *Middleware) FileSpaceOffload(cctx context.Context, req *pb.RpcFileSpac
|
|||
Error: &pb.RpcFileSpaceOffloadResponseError{Code: code},
|
||||
}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -118,7 +118,7 @@ func (mw *Middleware) FileUpload(cctx context.Context, req *pb.RpcFileUploadRequ
|
|||
response := func(objectId string, details *types.Struct, code pb.RpcFileUploadResponseErrorCode, err error) *pb.RpcFileUploadResponse {
|
||||
m := &pb.RpcFileUploadResponse{Error: &pb.RpcFileUploadResponseError{Code: code}, ObjectId: objectId, Details: details}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ func (mw *Middleware) FileSpaceUsage(cctx context.Context, req *pb.RpcFileSpaceU
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ func (mw *Middleware) FileReconcile(ctx context.Context, req *pb.RpcFileReconcil
|
|||
return &pb.RpcFileReconcileResponse{
|
||||
Error: &pb.RpcFileReconcileResponseError{
|
||||
Code: mapErrorCode[pb.RpcFileReconcileResponseErrorCode](err),
|
||||
Description: err.Error(),
|
||||
Description: getErrorDescription(err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/logging"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/mill"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
"github.com/anyproto/anytype-heart/util/uri"
|
||||
)
|
||||
|
||||
|
@ -327,7 +327,7 @@ func (u *uploader) SetFile(path string) Uploader {
|
|||
u.getReader = func(ctx context.Context) (*fileReader, error) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, oserror.TransformError(err)
|
||||
return nil, anyerror.CleanupError(err)
|
||||
}
|
||||
|
||||
buf := bufio.NewReaderSize(f, bufSize)
|
||||
|
|
|
@ -21,7 +21,7 @@ func (mw *Middleware) HistoryShowVersion(cctx context.Context, req *pb.RpcHistor
|
|||
}
|
||||
if err != nil {
|
||||
res.Error.Code = pb.RpcHistoryShowVersionResponseError_UNKNOWN_ERROR
|
||||
res.Error.Description = err.Error()
|
||||
res.Error.Description = getErrorDescription(err)
|
||||
return
|
||||
} else {
|
||||
res.ObjectView = obj
|
||||
|
@ -64,7 +64,7 @@ func (mw *Middleware) HistoryGetVersions(cctx context.Context, req *pb.RpcHistor
|
|||
}
|
||||
if err != nil {
|
||||
res.Error.Code = pb.RpcHistoryGetVersionsResponseError_UNKNOWN_ERROR
|
||||
res.Error.Description = err.Error()
|
||||
res.Error.Description = getErrorDescription(err)
|
||||
return
|
||||
} else {
|
||||
res.Versions = vers
|
||||
|
@ -102,7 +102,7 @@ func (mw *Middleware) HistorySetVersion(cctx context.Context, req *pb.RpcHistory
|
|||
}
|
||||
if err != nil {
|
||||
res.Error.Code = pb.RpcHistorySetVersionResponseError_UNKNOWN_ERROR
|
||||
res.Error.Description = err.Error()
|
||||
res.Error.Description = getErrorDescription(err)
|
||||
return
|
||||
}
|
||||
return
|
||||
|
@ -132,7 +132,7 @@ func (mw *Middleware) HistoryDiffVersions(cctx context.Context, req *pb.RpcHisto
|
|||
}
|
||||
if err != nil {
|
||||
res.Error.Code = pb.RpcHistoryDiffVersionsResponseError_UNKNOWN_ERROR
|
||||
res.Error.Description = err.Error()
|
||||
res.Error.Description = getErrorDescription(err)
|
||||
return
|
||||
}
|
||||
return
|
||||
|
|
|
@ -20,7 +20,7 @@ func (mw *Middleware) LinkPreview(cctx context.Context, req *pb.RpcLinkPreviewRe
|
|||
return &pb.RpcLinkPreviewResponse{
|
||||
Error: &pb.RpcLinkPreviewResponseError{
|
||||
Code: pb.RpcLinkPreviewResponseError_UNKNOWN_ERROR,
|
||||
Description: fmt.Sprintf("failed to parse url: %v", err),
|
||||
Description: fmt.Sprintf("failed to parse url: %v", getErrorDescription(err)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ func (mw *Middleware) LogSend(cctx context.Context, req *pb.RpcLogSendRequest) *
|
|||
response := func(code pb.RpcLogSendResponseErrorCode, err error) *pb.RpcLogSendResponse {
|
||||
m := &pb.RpcLogSendResponse{Error: &pb.RpcLogSendResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
|
@ -12,7 +12,7 @@ func (mw *Middleware) MetricsSetParameters(cctx context.Context, req *pb.RpcMetr
|
|||
response := func(code pb.RpcMetricsSetParametersResponseErrorCode, err error) *pb.RpcMetricsSetParametersResponse {
|
||||
m := &pb.RpcMetricsSetParametersResponse{Error: &pb.RpcMetricsSetParametersResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/anyproto/any-sync/net"
|
||||
|
||||
"github.com/anyproto/anytype-heart/core/nameservice"
|
||||
"github.com/anyproto/anytype-heart/pb"
|
||||
)
|
||||
|
@ -19,7 +20,7 @@ func (mw *Middleware) NameServiceResolveName(ctx context.Context, req *pb.RpcNam
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcNameServiceResolveNameResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
@ -46,7 +47,7 @@ func (mw *Middleware) NameServiceResolveAnyId(ctx context.Context, req *pb.RpcNa
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcNameServiceResolveAnyIdResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
@ -82,7 +83,7 @@ func (mw *Middleware) NameServiceUserAccountGet(ctx context.Context, req *pb.Rpc
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcNameServiceUserAccountGetResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ func (mw *Middleware) NavigationListObjects(cctx context.Context, req *pb.RpcNav
|
|||
response := func(code pb.RpcNavigationListObjectsResponseErrorCode, Objects []*model.ObjectInfo, err error) *pb.RpcNavigationListObjectsResponse {
|
||||
m := &pb.RpcNavigationListObjectsResponse{Error: &pb.RpcNavigationListObjectsResponseError{Code: code}, Objects: Objects}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ func (mw *Middleware) NavigationGetObjectInfoWithLinks(cctx context.Context, req
|
|||
response := func(code pb.RpcNavigationGetObjectInfoWithLinksResponseErrorCode, object *model.ObjectInfoWithLinks, err error) *pb.RpcNavigationGetObjectInfoWithLinksResponse {
|
||||
m := &pb.RpcNavigationGetObjectInfoWithLinksResponse{Error: &pb.RpcNavigationGetObjectInfoWithLinksResponseError{Code: code}, Object: object}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
|
@ -14,7 +14,7 @@ func (mw *Middleware) NotificationList(cctx context.Context, req *pb.RpcNotifica
|
|||
response := func(code pb.RpcNotificationListResponseErrorCode, notificationsList []*model.Notification, err error) *pb.RpcNotificationListResponse {
|
||||
m := &pb.RpcNotificationListResponse{Error: &pb.RpcNotificationListResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Notifications = notificationsList
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func (mw *Middleware) NotificationReply(cctx context.Context, req *pb.RpcNotific
|
|||
response := func(code pb.RpcNotificationReplyResponseErrorCode, err error) *pb.RpcNotificationReplyResponse {
|
||||
m := &pb.RpcNotificationReplyResponse{Error: &pb.RpcNotificationReplyResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func (mw *Middleware) NotificationTest(cctx context.Context, req *pb.RpcNotifica
|
|||
response := func(code pb.RpcNotificationTestResponseErrorCode, err error) *pb.RpcNotificationTestResponse {
|
||||
m := &pb.RpcNotificationTestResponse{Error: &pb.RpcNotificationTestResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ func (mw *Middleware) ObjectSetDetails(cctx context.Context, req *pb.RpcObjectSe
|
|||
response := func(code pb.RpcObjectSetDetailsResponseErrorCode, err error) *pb.RpcObjectSetDetailsResponse {
|
||||
m := &pb.RpcObjectSetDetailsResponse{Error: &pb.RpcObjectSetDetailsResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ func (mw *Middleware) ObjectDuplicate(cctx context.Context, req *pb.RpcObjectDup
|
|||
}
|
||||
if err != nil {
|
||||
m.Error.Code = pb.RpcObjectDuplicateResponseError_UNKNOWN_ERROR
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ func (mw *Middleware) ObjectListDuplicate(cctx context.Context, req *pb.RpcObjec
|
|||
}
|
||||
if err != nil {
|
||||
m.Error.Code = pb.RpcObjectListDuplicateResponseError_UNKNOWN_ERROR
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ func (mw *Middleware) ObjectSearch(cctx context.Context, req *pb.RpcObjectSearch
|
|||
response := func(code pb.RpcObjectSearchResponseErrorCode, records []*types.Struct, err error) *pb.RpcObjectSearchResponse {
|
||||
m := &pb.RpcObjectSearchResponse{Error: &pb.RpcObjectSearchResponseError{Code: code}, Records: records}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -147,7 +147,7 @@ func (mw *Middleware) ObjectSearchWithMeta(cctx context.Context, req *pb.RpcObje
|
|||
response := func(code pb.RpcObjectSearchWithMetaResponseErrorCode, results []*model.SearchResult, err error) *pb.RpcObjectSearchWithMetaResponse {
|
||||
m := &pb.RpcObjectSearchWithMetaResponse{Error: &pb.RpcObjectSearchWithMetaResponseError{Code: code}, Results: results}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -338,7 +338,7 @@ func (mw *Middleware) ObjectSearchSubscribe(cctx context.Context, req *pb.RpcObj
|
|||
},
|
||||
}
|
||||
if err != nil {
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ func (mw *Middleware) ObjectGroupsSubscribe(cctx context.Context, req *pb.RpcObj
|
|||
},
|
||||
}
|
||||
if err != nil {
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ func (mw *Middleware) ObjectSubscribeIds(_ context.Context, req *pb.RpcObjectSub
|
|||
},
|
||||
}
|
||||
if err != nil {
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ func (mw *Middleware) ObjectSearchUnsubscribe(cctx context.Context, req *pb.RpcO
|
|||
}
|
||||
if err != nil {
|
||||
r.Error.Code = pb.RpcObjectSearchUnsubscribeResponseError_UNKNOWN_ERROR
|
||||
r.Error.Description = err.Error()
|
||||
r.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ func (mw *Middleware) ObjectRelationAdd(cctx context.Context, req *pb.RpcObjectR
|
|||
response := func(code pb.RpcObjectRelationAddResponseErrorCode, err error) *pb.RpcObjectRelationAddResponse {
|
||||
m := &pb.RpcObjectRelationAddResponse{Error: &pb.RpcObjectRelationAddResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ func (mw *Middleware) ObjectRelationDelete(cctx context.Context, req *pb.RpcObje
|
|||
response := func(code pb.RpcObjectRelationDeleteResponseErrorCode, err error) *pb.RpcObjectRelationDeleteResponse {
|
||||
m := &pb.RpcObjectRelationDeleteResponse{Error: &pb.RpcObjectRelationDeleteResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ func (mw *Middleware) ObjectRelationListAvailable(cctx context.Context, req *pb.
|
|||
response := func(code pb.RpcObjectRelationListAvailableResponseErrorCode, relations []*model.Relation, err error) *pb.RpcObjectRelationListAvailableResponse {
|
||||
m := &pb.RpcObjectRelationListAvailableResponse{Relations: relations, Error: &pb.RpcObjectRelationListAvailableResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ func (mw *Middleware) ObjectSetObjectType(cctx context.Context, req *pb.RpcObjec
|
|||
response := func(code pb.RpcObjectSetObjectTypeResponseErrorCode, err error) *pb.RpcObjectSetObjectTypeResponse {
|
||||
m := &pb.RpcObjectSetObjectTypeResponse{Error: &pb.RpcObjectSetObjectTypeResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ func (mw *Middleware) ObjectListSetObjectType(cctx context.Context, req *pb.RpcO
|
|||
response := func(code pb.RpcObjectListSetObjectTypeResponseErrorCode, err error) *pb.RpcObjectListSetObjectTypeResponse {
|
||||
m := &pb.RpcObjectListSetObjectTypeResponse{Error: &pb.RpcObjectListSetObjectTypeResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -628,7 +628,7 @@ func (mw *Middleware) ObjectListSetDetails(cctx context.Context, req *pb.RpcObje
|
|||
response := func(code pb.RpcObjectListSetDetailsResponseErrorCode, err error) *pb.RpcObjectListSetDetailsResponse {
|
||||
m := &pb.RpcObjectListSetDetailsResponse{Error: &pb.RpcObjectListSetDetailsResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ func (mw *Middleware) ObjectSetLayout(cctx context.Context, req *pb.RpcObjectSet
|
|||
response := func(code pb.RpcObjectSetLayoutResponseErrorCode, err error) *pb.RpcObjectSetLayoutResponse {
|
||||
m := &pb.RpcObjectSetLayoutResponse{Error: &pb.RpcObjectSetLayoutResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -668,7 +668,7 @@ func (mw *Middleware) ObjectSetIsArchived(cctx context.Context, req *pb.RpcObjec
|
|||
response := func(code pb.RpcObjectSetIsArchivedResponseErrorCode, err error) *pb.RpcObjectSetIsArchivedResponse {
|
||||
m := &pb.RpcObjectSetIsArchivedResponse{Error: &pb.RpcObjectSetIsArchivedResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -687,7 +687,7 @@ func (mw *Middleware) ObjectSetSource(cctx context.Context,
|
|||
response := func(code pb.RpcObjectSetSourceResponseErrorCode, err error) *pb.RpcObjectSetSourceResponse {
|
||||
m := &pb.RpcObjectSetSourceResponse{Error: &pb.RpcObjectSetSourceResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ func (mw *Middleware) ObjectWorkspaceSetDashboard(cctx context.Context, req *pb.
|
|||
}
|
||||
if err != nil {
|
||||
resp.Error.Code = pb.RpcObjectWorkspaceSetDashboardResponseError_UNKNOWN_ERROR
|
||||
resp.Error.Description = err.Error()
|
||||
resp.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
resp.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -737,7 +737,7 @@ func (mw *Middleware) ObjectSetIsFavorite(cctx context.Context, req *pb.RpcObjec
|
|||
response := func(code pb.RpcObjectSetIsFavoriteResponseErrorCode, err error) *pb.RpcObjectSetIsFavoriteResponse {
|
||||
m := &pb.RpcObjectSetIsFavoriteResponse{Error: &pb.RpcObjectSetIsFavoriteResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -757,7 +757,7 @@ func (mw *Middleware) ObjectRelationAddFeatured(cctx context.Context, req *pb.Rp
|
|||
response := func(code pb.RpcObjectRelationAddFeaturedResponseErrorCode, err error) *pb.RpcObjectRelationAddFeaturedResponse {
|
||||
m := &pb.RpcObjectRelationAddFeaturedResponse{Error: &pb.RpcObjectRelationAddFeaturedResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -777,7 +777,7 @@ func (mw *Middleware) ObjectRelationRemoveFeatured(cctx context.Context, req *pb
|
|||
response := func(code pb.RpcObjectRelationRemoveFeaturedResponseErrorCode, err error) *pb.RpcObjectRelationRemoveFeaturedResponse {
|
||||
m := &pb.RpcObjectRelationRemoveFeaturedResponse{Error: &pb.RpcObjectRelationRemoveFeaturedResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -801,7 +801,7 @@ func (mw *Middleware) ObjectToSet(cctx context.Context, req *pb.RpcObjectToSetRe
|
|||
}
|
||||
if err != nil {
|
||||
resp.Error.Code = pb.RpcObjectToSetResponseError_UNKNOWN_ERROR
|
||||
resp.Error.Description = err.Error()
|
||||
resp.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
@ -815,7 +815,7 @@ func (mw *Middleware) ObjectBookmarkFetch(cctx context.Context, req *pb.RpcObjec
|
|||
response := func(code pb.RpcObjectBookmarkFetchResponseErrorCode, err error) *pb.RpcObjectBookmarkFetchResponse {
|
||||
m := &pb.RpcObjectBookmarkFetchResponse{Error: &pb.RpcObjectBookmarkFetchResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -834,7 +834,7 @@ func (mw *Middleware) ObjectToBookmark(cctx context.Context, req *pb.RpcObjectTo
|
|||
response := func(code pb.RpcObjectToBookmarkResponseErrorCode, id string, err error) *pb.RpcObjectToBookmarkResponse {
|
||||
m := &pb.RpcObjectToBookmarkResponse{Error: &pb.RpcObjectToBookmarkResponseError{Code: code}, ObjectId: id}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -857,7 +857,7 @@ func (mw *Middleware) ObjectSetInternalFlags(cctx context.Context, req *pb.RpcOb
|
|||
response := func(code pb.RpcObjectSetInternalFlagsResponseErrorCode, err error) *pb.RpcObjectSetInternalFlagsResponse {
|
||||
m := &pb.RpcObjectSetInternalFlagsResponse{Error: &pb.RpcObjectSetInternalFlagsResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -885,7 +885,7 @@ func (mw *Middleware) ObjectImport(cctx context.Context, req *pb.RpcObjectImport
|
|||
ObjectsCount: res.ObjectsCount,
|
||||
}
|
||||
if res.Err != nil {
|
||||
m.Error.Description = res.Err.Error()
|
||||
m.Error.Description = getErrorDescription(res.Err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -917,7 +917,7 @@ func (mw *Middleware) ObjectImportList(cctx context.Context, req *pb.RpcObjectIm
|
|||
response := func(res []*pb.RpcObjectImportListImportResponse, code pb.RpcObjectImportListResponseErrorCode, err error) *pb.RpcObjectImportListResponse {
|
||||
m := &pb.RpcObjectImportListResponse{Response: res, Error: &pb.RpcObjectImportListResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -974,7 +974,7 @@ func (mw *Middleware) ObjectImportUseCase(cctx context.Context, req *pb.RpcObjec
|
|||
},
|
||||
}
|
||||
if err != nil {
|
||||
resp.Error.Description = err.Error()
|
||||
resp.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
resp.Event = ctx.GetResponseEvent()
|
||||
}
|
||||
|
@ -993,7 +993,7 @@ func (mw *Middleware) ObjectImportExperience(ctx context.Context, req *pb.RpcObj
|
|||
},
|
||||
}
|
||||
if err != nil {
|
||||
resp.Error.Description = err.Error()
|
||||
resp.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ func (mw *Middleware) ObjectShareByLink(cctx context.Context, req *pb.RpcObjectS
|
|||
response := func(link string, code pb.RpcObjectShareByLinkResponseErrorCode, err error) *pb.RpcObjectShareByLinkResponse {
|
||||
m := &pb.RpcObjectShareByLinkResponse{Link: link, Error: &pb.RpcObjectShareByLinkResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
|
@ -39,7 +39,7 @@ func (mw *Middleware) MembershipGetStatus(ctx context.Context, req *pb.RpcMember
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcMembershipGetStatusResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ func (mw *Middleware) MembershipIsNameValid(ctx context.Context, req *pb.RpcMemb
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcMembershipIsNameValidResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func (mw *Middleware) MembershipRegisterPaymentRequest(ctx context.Context, req
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcMembershipRegisterPaymentRequestResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ func (mw *Middleware) MembershipGetPortalLinkUrl(ctx context.Context, req *pb.Rp
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcMembershipGetPortalLinkUrlResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ func (mw *Middleware) MembershipGetVerificationEmail(ctx context.Context, req *p
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcMembershipGetVerificationEmailResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ func (mw *Middleware) MembershipVerifyEmailCode(ctx context.Context, req *pb.Rpc
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcMembershipVerifyEmailCodeResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ func (mw *Middleware) MembershipFinalize(ctx context.Context, req *pb.RpcMembers
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcMembershipFinalizeResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ func (mw *Middleware) MembershipGetTiers(ctx context.Context, req *pb.RpcMembers
|
|||
)
|
||||
|
||||
// if client doesn't handle that error - let it show unlocalized string at least
|
||||
errStr := err.Error()
|
||||
errStr := getErrorDescription(err)
|
||||
if code == pb.RpcMembershipGetTiersResponseError_CAN_NOT_CONNECT {
|
||||
errStr = "please connect to the internet"
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ func (mw *Middleware) MembershipVerifyAppStoreReceipt(ctx context.Context, req *
|
|||
return &pb.RpcMembershipVerifyAppStoreReceiptResponse{
|
||||
Error: &pb.RpcMembershipVerifyAppStoreReceiptResponseError{
|
||||
Code: code,
|
||||
Description: err.Error(),
|
||||
Description: getErrorDescription(err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func (mw *Middleware) DebugPing(cctx context.Context, req *pb.RpcDebugPingReques
|
|||
response := func(index int32, code pb.RpcDebugPingResponseErrorCode, err error) *pb.RpcDebugPingResponse {
|
||||
m := &pb.RpcDebugPingResponse{Index: index, Error: &pb.RpcDebugPingResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
n = time.Now()
|
||||
|
|
|
@ -11,7 +11,7 @@ func (mw *Middleware) ProcessCancel(cctx context.Context, req *pb.RpcProcessCanc
|
|||
response := func(code pb.RpcProcessCancelResponseErrorCode, err error) *pb.RpcProcessCancelResponse {
|
||||
m := &pb.RpcProcessCancelResponse{Error: &pb.RpcProcessCancelResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ func (mw *Middleware) RelationListRemoveOption(cctx context.Context, request *pb
|
|||
return &pb.RpcRelationListRemoveOptionResponse{
|
||||
Error: &pb.RpcRelationListRemoveOptionResponseError{
|
||||
Code: code,
|
||||
Description: err.Error(),
|
||||
Description: getErrorDescription(err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ func (mw *Middleware) BlockTableCreate(cctx context.Context, req *pb.RpcBlockTab
|
|||
response := func(code pb.RpcBlockTableCreateResponseErrorCode, id string, err error) *pb.RpcBlockTableCreateResponse {
|
||||
m := &pb.RpcBlockTableCreateResponse{Error: &pb.RpcBlockTableCreateResponseError{Code: code}, BlockId: id}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ func (mw *Middleware) BlockTableRowCreate(cctx context.Context, req *pb.RpcBlock
|
|||
response := func(code pb.RpcBlockTableRowCreateResponseErrorCode, id string, err error) *pb.RpcBlockTableRowCreateResponse {
|
||||
m := &pb.RpcBlockTableRowCreateResponse{Error: &pb.RpcBlockTableRowCreateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ func (mw *Middleware) BlockTableColumnCreate(cctx context.Context, req *pb.RpcBl
|
|||
response := func(code pb.RpcBlockTableColumnCreateResponseErrorCode, id string, err error) *pb.RpcBlockTableColumnCreateResponse {
|
||||
m := &pb.RpcBlockTableColumnCreateResponse{Error: &pb.RpcBlockTableColumnCreateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ func (mw *Middleware) BlockTableRowDelete(cctx context.Context, req *pb.RpcBlock
|
|||
response := func(code pb.RpcBlockTableRowDeleteResponseErrorCode, id string, err error) *pb.RpcBlockTableRowDeleteResponse {
|
||||
m := &pb.RpcBlockTableRowDeleteResponse{Error: &pb.RpcBlockTableRowDeleteResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ func (mw *Middleware) BlockTableColumnDelete(cctx context.Context, req *pb.RpcBl
|
|||
response := func(code pb.RpcBlockTableColumnDeleteResponseErrorCode, id string, err error) *pb.RpcBlockTableColumnDeleteResponse {
|
||||
m := &pb.RpcBlockTableColumnDeleteResponse{Error: &pb.RpcBlockTableColumnDeleteResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ func (mw *Middleware) BlockTableColumnMove(cctx context.Context, req *pb.RpcBloc
|
|||
response := func(code pb.RpcBlockTableColumnMoveResponseErrorCode, id string, err error) *pb.RpcBlockTableColumnMoveResponse {
|
||||
m := &pb.RpcBlockTableColumnMoveResponse{Error: &pb.RpcBlockTableColumnMoveResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ func (mw *Middleware) BlockTableRowDuplicate(cctx context.Context, req *pb.RpcBl
|
|||
response := func(code pb.RpcBlockTableRowDuplicateResponseErrorCode, id string, err error) *pb.RpcBlockTableRowDuplicateResponse {
|
||||
m := &pb.RpcBlockTableRowDuplicateResponse{Error: &pb.RpcBlockTableRowDuplicateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func (mw *Middleware) BlockTableColumnDuplicate(cctx context.Context, req *pb.Rp
|
|||
response := func(code pb.RpcBlockTableColumnDuplicateResponseErrorCode, id string, err error) *pb.RpcBlockTableColumnDuplicateResponse {
|
||||
m := &pb.RpcBlockTableColumnDuplicateResponse{BlockId: id, Error: &pb.RpcBlockTableColumnDuplicateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ func (mw *Middleware) BlockTableExpand(cctx context.Context, req *pb.RpcBlockTab
|
|||
response := func(code pb.RpcBlockTableExpandResponseErrorCode, id string, err error) *pb.RpcBlockTableExpandResponse {
|
||||
m := &pb.RpcBlockTableExpandResponse{Error: &pb.RpcBlockTableExpandResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ func (mw *Middleware) BlockTableRowListFill(cctx context.Context, req *pb.RpcBlo
|
|||
response := func(code pb.RpcBlockTableRowListFillResponseErrorCode, id string, err error) *pb.RpcBlockTableRowListFillResponse {
|
||||
m := &pb.RpcBlockTableRowListFillResponse{Error: &pb.RpcBlockTableRowListFillResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ func (mw *Middleware) BlockTableRowListClean(cctx context.Context, req *pb.RpcBl
|
|||
response := func(code pb.RpcBlockTableRowListCleanResponseErrorCode, id string, err error) *pb.RpcBlockTableRowListCleanResponse {
|
||||
m := &pb.RpcBlockTableRowListCleanResponse{Error: &pb.RpcBlockTableRowListCleanResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ func (mw *Middleware) BlockTableSort(cctx context.Context, req *pb.RpcBlockTable
|
|||
response := func(code pb.RpcBlockTableSortResponseErrorCode, id string, err error) *pb.RpcBlockTableSortResponse {
|
||||
m := &pb.RpcBlockTableSortResponse{Error: &pb.RpcBlockTableSortResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ func (mw *Middleware) BlockTableColumnListFill(cctx context.Context, req *pb.Rpc
|
|||
response := func(code pb.RpcBlockTableColumnListFillResponseErrorCode, id string, err error) *pb.RpcBlockTableColumnListFillResponse {
|
||||
m := &pb.RpcBlockTableColumnListFillResponse{Error: &pb.RpcBlockTableColumnListFillResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ func (mw *Middleware) BlockTableRowSetHeader(cctx context.Context, req *pb.RpcBl
|
|||
response := func(code pb.RpcBlockTableRowSetHeaderResponseErrorCode, id string, err error) *pb.RpcBlockTableRowSetHeaderResponse {
|
||||
m := &pb.RpcBlockTableRowSetHeaderResponse{Error: &pb.RpcBlockTableRowSetHeaderResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ func (mw *Middleware) TemplateCreateFromObject(ctx context.Context, req *pb.RpcT
|
|||
}
|
||||
if err != nil {
|
||||
m.Error.Code = pb.RpcTemplateCreateFromObjectResponseError_UNKNOWN_ERROR
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ func (mw *Middleware) TemplateClone(_ context.Context, req *pb.RpcTemplateCloneR
|
|||
}
|
||||
if err != nil {
|
||||
m.Error.Code = pb.RpcTemplateCloneResponseError_UNKNOWN_ERROR
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ func (mw *Middleware) ObjectApplyTemplate(_ context.Context, req *pb.RpcObjectAp
|
|||
}
|
||||
if err != nil {
|
||||
m.Error.Code = pb.RpcObjectApplyTemplateResponseError_UNKNOWN_ERROR
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ func (mw *Middleware) TemplateExportAll(ctx context.Context, req *pb.RpcTemplate
|
|||
}
|
||||
if err != nil {
|
||||
res.Error.Code = pb.RpcTemplateExportAllResponseError_UNKNOWN_ERROR
|
||||
res.Error.Description = err.Error()
|
||||
res.Error.Description = getErrorDescription(err)
|
||||
return
|
||||
} else {
|
||||
res.Path = path
|
||||
|
|
|
@ -19,7 +19,7 @@ func (mw *Middleware) ObjectUndo(cctx context.Context, req *pb.RpcObjectUndoRequ
|
|||
response := func(code pb.RpcObjectUndoResponseErrorCode, err error) *pb.RpcObjectUndoResponse {
|
||||
m := &pb.RpcObjectUndoResponse{Error: &pb.RpcObjectUndoResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
m.Counters = &info.Counters
|
||||
|
@ -53,7 +53,7 @@ func (mw *Middleware) ObjectRedo(cctx context.Context, req *pb.RpcObjectRedoRequ
|
|||
response := func(code pb.RpcObjectRedoResponseErrorCode, err error) *pb.RpcObjectRedoResponse {
|
||||
m := &pb.RpcObjectRedoResponse{Error: &pb.RpcObjectRedoResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
m.Counters = &info.Counters
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/anyproto/anytype-heart/core/session"
|
||||
"github.com/anyproto/anytype-heart/pb"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
func (mw *Middleware) getResponseEvent(ctx session.Context) *pb.ResponseEvent {
|
||||
|
@ -44,7 +45,7 @@ func getErrorDescription(err error) string {
|
|||
if err == nil {
|
||||
return ""
|
||||
}
|
||||
return err.Error()
|
||||
return anyerror.CleanupError(err).Error()
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -11,7 +11,7 @@ func (mw *Middleware) AppGetVersion(cctx context.Context, req *pb.RpcAppGetVersi
|
|||
response := func(version, details string, code pb.RpcAppGetVersionResponseErrorCode, err error) *pb.RpcAppGetVersionResponse {
|
||||
m := &pb.RpcAppGetVersionResponse{Version: version, Details: details, Error: &pb.RpcAppGetVersionResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
|
@ -12,7 +12,7 @@ func (mw *Middleware) BlockCreateWidget(cctx context.Context, req *pb.RpcBlockCr
|
|||
response := func(code pb.RpcBlockCreateWidgetResponseErrorCode, id string, err error) *pb.RpcBlockCreateWidgetResponse {
|
||||
m := &pb.RpcBlockCreateWidgetResponse{Error: &pb.RpcBlockCreateWidgetResponseError{Code: code}, BlockId: id}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ func (mw *Middleware) BlockWidgetSetTargetId(cctx context.Context, req *pb.RpcBl
|
|||
response := func(code pb.RpcBlockWidgetSetTargetIdResponseErrorCode, id string, err error) *pb.RpcBlockWidgetSetTargetIdResponse {
|
||||
m := &pb.RpcBlockWidgetSetTargetIdResponse{Error: &pb.RpcBlockWidgetSetTargetIdResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ func (mw *Middleware) BlockWidgetSetLayout(cctx context.Context, req *pb.RpcBloc
|
|||
response := func(code pb.RpcBlockWidgetSetLayoutResponseErrorCode, id string, err error) *pb.RpcBlockWidgetSetLayoutResponse {
|
||||
m := &pb.RpcBlockWidgetSetLayoutResponse{Error: &pb.RpcBlockWidgetSetLayoutResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func (mw *Middleware) BlockWidgetSetLimit(cctx context.Context, req *pb.RpcBlock
|
|||
response := func(code pb.RpcBlockWidgetSetLimitResponseErrorCode, id string, err error) *pb.RpcBlockWidgetSetLimitResponse {
|
||||
m := &pb.RpcBlockWidgetSetLimitResponse{Error: &pb.RpcBlockWidgetSetLimitResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ func (mw *Middleware) BlockWidgetSetViewId(cctx context.Context, req *pb.RpcBloc
|
|||
response := func(code pb.RpcBlockWidgetSetViewIdResponseErrorCode, id string, err error) *pb.RpcBlockWidgetSetViewIdResponse {
|
||||
m := &pb.RpcBlockWidgetSetViewIdResponse{Error: &pb.RpcBlockWidgetSetViewIdResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
} else {
|
||||
m.Event = mw.getResponseEvent(ctx)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ func (mw *Middleware) WorkspaceCreate(cctx context.Context, req *pb.RpcWorkspace
|
|||
response := func(workspaceId string, code pb.RpcWorkspaceCreateResponseErrorCode, err error) *pb.RpcWorkspaceCreateResponse {
|
||||
m := &pb.RpcWorkspaceCreateResponse{SpaceId: workspaceId, Error: &pb.RpcWorkspaceCreateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -42,7 +42,7 @@ func (mw *Middleware) WorkspaceOpen(cctx context.Context, req *pb.RpcWorkspaceOp
|
|||
Error: &pb.RpcWorkspaceOpenResponseError{Code: code},
|
||||
}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ func (mw *Middleware) WorkspaceSetInfo(cctx context.Context, req *pb.RpcWorkspac
|
|||
response := func(code pb.RpcWorkspaceSetInfoResponseErrorCode, err error) *pb.RpcWorkspaceSetInfoResponse {
|
||||
m := &pb.RpcWorkspaceSetInfoResponse{Error: &pb.RpcWorkspaceSetInfoResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -89,7 +89,7 @@ func (mw *Middleware) WorkspaceSelect(cctx context.Context, req *pb.RpcWorkspace
|
|||
response := func(code pb.RpcWorkspaceSelectResponseErrorCode, err error) *pb.RpcWorkspaceSelectResponse {
|
||||
m := &pb.RpcWorkspaceSelectResponse{Error: &pb.RpcWorkspaceSelectResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -109,7 +109,7 @@ func (mw *Middleware) WorkspaceGetAll(cctx context.Context, req *pb.RpcWorkspace
|
|||
response := func(workspaceIds []string, code pb.RpcWorkspaceGetAllResponseErrorCode, err error) *pb.RpcWorkspaceGetAllResponse {
|
||||
m := &pb.RpcWorkspaceGetAllResponse{WorkspaceIds: workspaceIds, Error: &pb.RpcWorkspaceGetAllResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -131,7 +131,7 @@ func (mw *Middleware) WorkspaceGetCurrent(cctx context.Context, req *pb.RpcWorks
|
|||
response := func(workspaceId string, code pb.RpcWorkspaceGetCurrentResponseErrorCode, err error) *pb.RpcWorkspaceGetCurrentResponse {
|
||||
m := &pb.RpcWorkspaceGetCurrentResponse{WorkspaceId: workspaceId, Error: &pb.RpcWorkspaceGetCurrentResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -154,7 +154,7 @@ func (mw *Middleware) WorkspaceObjectListAdd(cctx context.Context, req *pb.RpcWo
|
|||
response := func(ids []string, code pb.RpcWorkspaceObjectListAddResponseErrorCode, err error) *pb.RpcWorkspaceObjectListAddResponse {
|
||||
m := &pb.RpcWorkspaceObjectListAddResponse{ObjectIds: ids, Error: &pb.RpcWorkspaceObjectListAddResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -180,7 +180,7 @@ func (mw *Middleware) WorkspaceObjectAdd(cctx context.Context, req *pb.RpcWorksp
|
|||
response := func(id string, details *types.Struct, code pb.RpcWorkspaceObjectAddResponseErrorCode, err error) *pb.RpcWorkspaceObjectAddResponse {
|
||||
m := &pb.RpcWorkspaceObjectAddResponse{ObjectId: id, Details: details, Error: &pb.RpcWorkspaceObjectAddResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -207,7 +207,7 @@ func (mw *Middleware) WorkspaceObjectListRemove(cctx context.Context, req *pb.Rp
|
|||
response := func(ids []string, code pb.RpcWorkspaceObjectListRemoveResponseErrorCode, err error) *pb.RpcWorkspaceObjectListRemoveResponse {
|
||||
m := &pb.RpcWorkspaceObjectListRemoveResponse{Ids: ids, Error: &pb.RpcWorkspaceObjectListRemoveResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
m.Error.Description = getErrorDescription(err)
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/datastore"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/logging"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore/storage"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -168,7 +168,7 @@ func (r *clientds) Init(a *app.App) (err error) {
|
|||
opts.ValueDir = opts.Dir
|
||||
|
||||
r.localstoreDS, err = openBadgerWithRecover(opts)
|
||||
err = oserror.TransformError(err)
|
||||
err = anyerror.CleanupError(err)
|
||||
if err != nil && isBadgerCorrupted(err) {
|
||||
// because localstore contains mostly recoverable info (with th only exception of objects' lastOpenedDate)
|
||||
// we can just remove and recreate it
|
||||
|
@ -176,7 +176,7 @@ func (r *clientds) Init(a *app.App) (err error) {
|
|||
log.Errorf("failed to rename corrupted localstore: %s", err2)
|
||||
var errAfterRemove error
|
||||
r.localstoreDS, errAfterRemove = openBadgerWithRecover(opts)
|
||||
errAfterRemove = oserror.TransformError(errAfterRemove)
|
||||
errAfterRemove = anyerror.CleanupError(errAfterRemove)
|
||||
log.With("db", "localstore").With("reset", true).With("err_remove", errAfterRemove).With("err", err.Error()).Errorf("failed to open db")
|
||||
if errAfterRemove != nil {
|
||||
// should not happen, but just in case
|
||||
|
@ -193,7 +193,7 @@ func (r *clientds) Init(a *app.App) (err error) {
|
|||
opts.ValueDir = opts.Dir
|
||||
r.spaceDS, err = openBadgerWithRecover(opts)
|
||||
if err != nil {
|
||||
err = oserror.TransformError(err)
|
||||
err = anyerror.CleanupError(err)
|
||||
log.With("db", "spacestore").With("reset", false).With("err", err.Error()).Errorf("failed to open db")
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
)
|
||||
|
||||
type Sugared struct {
|
||||
|
@ -67,41 +63,8 @@ func (s *Sugared) Infow(msg string, keysAndValues ...interface{}) {
|
|||
func cleanupArgs(args []interface{}) {
|
||||
for i, arg := range args {
|
||||
if err, ok := arg.(error); ok {
|
||||
err = cleanupError(err)
|
||||
err = anyerror.CleanupError(err)
|
||||
args[i] = err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func cleanUpCase[T error](result string, originalErr error, proc func(T)) string {
|
||||
var wrappedErr T
|
||||
if errors.As(originalErr, &wrappedErr) {
|
||||
prevWrappedString := wrappedErr.Error()
|
||||
proc(wrappedErr)
|
||||
result = strings.Replace(result, prevWrappedString, wrappedErr.Error(), 1)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func cleanupError(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
result := err.Error()
|
||||
|
||||
result = cleanUpCase(result, err, func(pathErr *os.PathError) {
|
||||
pathErr.Path = "<masked file path>"
|
||||
})
|
||||
result = cleanUpCase(result, err, func(urlErr *url.Error) {
|
||||
urlErr.URL = "<masked url>"
|
||||
})
|
||||
result = cleanUpCase(result, err, func(dnsErr *net.DNSError) {
|
||||
if dnsErr.Name != "" {
|
||||
dnsErr.Name = "<masked host name>"
|
||||
}
|
||||
if dnsErr.Server != "" {
|
||||
dnsErr.Server = "<masked dns server>"
|
||||
}
|
||||
})
|
||||
return errors.New(result)
|
||||
}
|
||||
|
|
68
util/anyerror/anyerror.go
Normal file
68
util/anyerror/anyerror.go
Normal file
|
@ -0,0 +1,68 @@
|
|||
package anyerror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// badgerFileErrPattern is a regular expression pattern to match file paths in badger errors.
|
||||
// seems like all badger errors with file paths have this pattern.
|
||||
var badgerFileErrPattern = regexp.MustCompile(`file: (.*?), error:`)
|
||||
|
||||
// anonymizeBadgerError anonymizes a non-typed badger errors that contain file paths.
|
||||
func anonymizeBadgerError(err string, changed bool) (string, bool) {
|
||||
if submatch := badgerFileErrPattern.FindStringSubmatch(err); len(submatch) > 0 {
|
||||
if len(submatch) > 0 {
|
||||
anonymizedPath := "*" + string(os.PathSeparator) + filepath.Base(strings.TrimSpace(submatch[1]))
|
||||
err = strings.Replace(err, submatch[1], anonymizedPath, 1)
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
return err, changed
|
||||
}
|
||||
|
||||
func CleanupError(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
result := err.Error()
|
||||
var errChanged bool
|
||||
result = cleanUpCase(result, err, func(pathErr *os.PathError) {
|
||||
pathErr.Path = "<masked file path>"
|
||||
errChanged = true
|
||||
})
|
||||
result = cleanUpCase(result, err, func(urlErr *url.Error) {
|
||||
urlErr.URL = "<masked url>"
|
||||
errChanged = true
|
||||
})
|
||||
result = cleanUpCase(result, err, func(dnsErr *net.DNSError) {
|
||||
if dnsErr.Name != "" {
|
||||
dnsErr.Name = "<masked host name>"
|
||||
errChanged = true
|
||||
}
|
||||
if dnsErr.Server != "" {
|
||||
dnsErr.Server = "<masked dns server>"
|
||||
errChanged = true
|
||||
}
|
||||
})
|
||||
result, errChanged = anonymizeBadgerError(result, errChanged)
|
||||
if errChanged {
|
||||
return errors.New(result)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func cleanUpCase[T error](result string, originalErr error, proc func(T)) string {
|
||||
var wrappedErr T
|
||||
if errors.As(originalErr, &wrappedErr) {
|
||||
prevWrappedString := wrappedErr.Error()
|
||||
proc(wrappedErr)
|
||||
result = strings.Replace(result, prevWrappedString, wrappedErr.Error(), 1)
|
||||
}
|
||||
return result
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package os
|
||||
package anyerror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -22,9 +22,9 @@ func TestTransformError(t *testing.T) {
|
|||
Err: fmt.Errorf("test"),
|
||||
}
|
||||
|
||||
resultErrorMessage := "read /***/***/***/: test"
|
||||
assert.NotNil(t, TransformError(pathError))
|
||||
assert.Equal(t, resultErrorMessage, TransformError(pathError).Error())
|
||||
resultErrorMessage := "read <masked file path>: test"
|
||||
assert.NotNil(t, CleanupError(pathError))
|
||||
assert.Equal(t, resultErrorMessage, CleanupError(pathError).Error())
|
||||
})
|
||||
|
||||
t.Run("relative path", func(t *testing.T) {
|
||||
|
@ -34,23 +34,23 @@ func TestTransformError(t *testing.T) {
|
|||
Err: fmt.Errorf("test"),
|
||||
}
|
||||
|
||||
resultErrorMessage := "read ***/***: test"
|
||||
assert.NotNil(t, TransformError(pathError))
|
||||
assert.Equal(t, resultErrorMessage, TransformError(pathError).Error())
|
||||
resultErrorMessage := "read <masked file path>: test"
|
||||
assert.NotNil(t, CleanupError(pathError))
|
||||
assert.Equal(t, resultErrorMessage, CleanupError(pathError).Error())
|
||||
})
|
||||
|
||||
t.Run("not os path error", func(t *testing.T) {
|
||||
err := fmt.Errorf("test")
|
||||
resultErrorMessage := "test"
|
||||
assert.NotNil(t, TransformError(err))
|
||||
assert.Equal(t, resultErrorMessage, TransformError(err).Error())
|
||||
assert.NotNil(t, CleanupError(err))
|
||||
assert.Equal(t, resultErrorMessage, CleanupError(err).Error())
|
||||
})
|
||||
|
||||
t.Run("url error", func(t *testing.T) {
|
||||
err := &url.Error{URL: "http://test.test", Op: "Test", Err: fmt.Errorf("test")}
|
||||
resultErrorMessage := "Test \"<masked url>\": test"
|
||||
assert.NotNil(t, TransformError(err))
|
||||
assert.Equal(t, resultErrorMessage, TransformError(err).Error())
|
||||
assert.NotNil(t, CleanupError(err))
|
||||
assert.Equal(t, resultErrorMessage, CleanupError(err).Error())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -64,13 +64,6 @@ func Test_transformBadgerError(t *testing.T) {
|
|||
args args
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
name: "nil error",
|
||||
args: args{
|
||||
err: nil,
|
||||
},
|
||||
wantErr: nil,
|
||||
},
|
||||
{
|
||||
name: "badger error win",
|
||||
pathseparator: "\\",
|
||||
|
@ -93,14 +86,15 @@ func Test_transformBadgerError(t *testing.T) {
|
|||
if tt.pathseparator != "" && tt.pathseparator != string(os.PathSeparator) {
|
||||
t.Skipf("Test is not applicable for the current platform")
|
||||
}
|
||||
resultErr := anonymizeBadgerError(tt.args.err)
|
||||
resultErr, _ := anonymizeBadgerError(tt.args.err.Error(), false)
|
||||
|
||||
if tt.wantErr == nil {
|
||||
require.Nil(t, resultErr)
|
||||
require.Empty(t, resultErr)
|
||||
return
|
||||
}
|
||||
|
||||
require.EqualError(t, anonymizeBadgerError(tt.args.err), tt.wantErr.Error())
|
||||
badgerError, _ := anonymizeBadgerError(tt.args.err.Error(), false)
|
||||
require.Equal(t, badgerError, tt.wantErr.Error())
|
||||
})
|
||||
}
|
||||
}
|
|
@ -38,8 +38,8 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
|
||||
"github.com/anyproto/anytype-heart/space"
|
||||
"github.com/anyproto/anytype-heart/space/clientspace"
|
||||
"github.com/anyproto/anytype-heart/util/anyerror"
|
||||
"github.com/anyproto/anytype-heart/util/constant"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/pbtypes"
|
||||
"github.com/anyproto/anytype-heart/util/uri"
|
||||
)
|
||||
|
@ -251,7 +251,7 @@ func (b *builtinObjects) CreateObjectsForExperience(ctx context.Context, spaceID
|
|||
}
|
||||
removeFunc = func() {
|
||||
if rmErr := os.Remove(path); rmErr != nil {
|
||||
log.Errorf("failed to remove temporary file: %v", oserror.TransformError(rmErr))
|
||||
log.Errorf("failed to remove temporary file: %v", anyerror.CleanupError(rmErr))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ func (b *builtinObjects) inject(ctx session.Context, spaceID string, useCase pb.
|
|||
// TODO: GO-2627 Home page handling should be moved to importer
|
||||
b.handleHomePage(path, spaceID, func() {
|
||||
if rmErr := os.Remove(path); rmErr != nil {
|
||||
log.Errorf("failed to remove temporary file: %v", oserror.TransformError(rmErr))
|
||||
log.Errorf("failed to remove temporary file: %v", anyerror.CleanupError(rmErr))
|
||||
}
|
||||
}, useCase == migrationUseCase)
|
||||
|
||||
|
@ -523,7 +523,7 @@ func (b *builtinObjects) downloadZipToFile(url string, progress process.Progress
|
|||
var out *os.File
|
||||
out, err = os.Create(path)
|
||||
if err != nil {
|
||||
return "", oserror.TransformError(err)
|
||||
return "", anyerror.CleanupError(err)
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
package os
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
// badgerFileErrPattern is a regular expression pattern to match file paths in badger errors.
|
||||
// seems like all badger errors with file paths have this pattern.
|
||||
var badgerFileErrPattern = regexp.MustCompile(`file: (.*?), error:`)
|
||||
|
||||
// anonymizeBadgerError anonymizes a non-typed badger errors that contain file paths.
|
||||
func anonymizeBadgerError(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if submatch := badgerFileErrPattern.FindStringSubmatch(err.Error()); len(submatch) > 0 {
|
||||
if len(submatch) > 0 {
|
||||
anonymizedPath := "*" + string(os.PathSeparator) + filepath.Base(strings.TrimSpace(submatch[1]))
|
||||
err = errors.New(strings.Replace(err.Error(), submatch[1], anonymizedPath, 1))
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func TransformError(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if pathErr, ok := err.(*os.PathError); ok {
|
||||
return anonymizePathError(pathErr)
|
||||
}
|
||||
if urlErr, ok := err.(*url.Error); ok {
|
||||
return anonymizeUrlError(urlErr)
|
||||
}
|
||||
|
||||
return anonymizeBadgerError(err)
|
||||
}
|
||||
|
||||
func anonymizePathError(pathErr *os.PathError) error {
|
||||
filePathParts := strings.Split(pathErr.Path, string(filepath.Separator))
|
||||
anonymizedFilePathParts := lo.Map(filePathParts, func(item string, index int) string {
|
||||
if item == "" {
|
||||
return ""
|
||||
}
|
||||
return strings.ReplaceAll(item, item, "***")
|
||||
})
|
||||
newPath := strings.Join(anonymizedFilePathParts, string(filepath.Separator))
|
||||
pathErr.Path = newPath
|
||||
return pathErr
|
||||
}
|
||||
|
||||
func anonymizeUrlError(urlErr *url.Error) error {
|
||||
urlErr.URL = "<masked url>"
|
||||
return urlErr
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue