mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-07 21:37:04 +09:00
GO-1943: Fix some wrapped errors
This commit is contained in:
parent
15db45b692
commit
9df1eb8ecd
5 changed files with 15 additions and 16 deletions
|
@ -298,14 +298,14 @@ func getTargetBlock(importContext *api.NotionImportContext, pageIDToName, notion
|
|||
if targetBlockID, ok = notionIDsToAnytype[id]; ok {
|
||||
return targetBlockID, nil
|
||||
} else {
|
||||
err = fmt.Errorf("%s '%s'", objectNotFoundMessage, title)
|
||||
err = fmt.Errorf("%s '%s'", objectNotFoundMessage, hashText(title))
|
||||
log.With("notionID", hashText(id)).With("title", hashText(title)).Errorf("getTargetBlock: anytype id not found")
|
||||
}
|
||||
} else if len(idsWithGivenName) > 1 {
|
||||
err = fmt.Errorf("%s '%s'", ambiguousPageMessage, title)
|
||||
err = fmt.Errorf("%s '%s'", ambiguousPageMessage, hashText(title))
|
||||
log.With("title", hashText(title)).With("options", len(idsWithGivenName)).Warnf("getTargetBlock: ambligious page title")
|
||||
} else {
|
||||
err = fmt.Errorf("%s '%s'", pageNotFoundMessage, title)
|
||||
err = fmt.Errorf("%s '%s'", pageNotFoundMessage, hashText(title))
|
||||
log.With("title", hashText(title)).Errorf("getTargetBlock: target not found")
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ func validateToken(privKey []byte, rawToken string) error {
|
|||
return privKey, nil
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("parse token %s: %w", rawToken, err)
|
||||
return fmt.Errorf("parse token: %w", err)
|
||||
}
|
||||
|
||||
if token != nil && !token.Valid {
|
||||
|
|
|
@ -535,7 +535,7 @@ func (s *service) filtersFromSource(spaceID string, sources []string) (database.
|
|||
for _, relationID := range idsByType[smartblock.SmartBlockTypeRelation] {
|
||||
relationDetails, err := s.objectStore.GetDetails(relationID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get relation %s details: %w", relationDetails, err)
|
||||
return nil, fmt.Errorf("get relation %s details: %w", relationID, err)
|
||||
}
|
||||
relTypeFilter = append(relTypeFilter, database.FilterExists{
|
||||
Key: pbtypes.GetString(relationDetails.Details, bundle.RelationKeyRelationKey.String()),
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"archive/zip"
|
||||
"bytes"
|
||||
"context"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
@ -29,8 +30,6 @@ import (
|
|||
"github.com/anyproto/anytype-heart/util/constant"
|
||||
oserror "github.com/anyproto/anytype-heart/util/os"
|
||||
"github.com/anyproto/anytype-heart/util/pbtypes"
|
||||
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -195,7 +194,7 @@ func (b *builtinObjects) CreateObjectsForExperience(ctx context.Context, spaceID
|
|||
return err
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("failed to fetch experience from '%s': not OK status code: %s", source, resp.Status)
|
||||
return fmt.Errorf("failed to fetch experience: not OK status code: %s", resp.Status)
|
||||
}
|
||||
defer func() {
|
||||
if err = resp.Body.Close(); err != nil {
|
||||
|
@ -237,7 +236,7 @@ func (b *builtinObjects) InjectMigrationDashboard(spaceID string) error {
|
|||
func (b *builtinObjects) inject(ctx session.Context, spaceID string, useCase pb.RpcObjectImportUseCaseRequestUseCase, archive []byte) (err error) {
|
||||
path := filepath.Join(b.tempDirService.TempDir(), time.Now().Format("tmp.20060102.150405.99")+".zip")
|
||||
if err = os.WriteFile(path, archive, 0644); err != nil {
|
||||
return fmt.Errorf("failed to save use case archive to temporary file: %s", err)
|
||||
return fmt.Errorf("failed to save use case archive to temporary file: %w", err)
|
||||
}
|
||||
|
||||
if err = b.importArchive(context.Background(), spaceID, path); err != nil {
|
||||
|
|
|
@ -238,23 +238,23 @@ func (l *unsplashService) Download(ctx context.Context, id string) (imgPath stri
|
|||
client := http.DefaultClient
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to download file from unsplash: %s", err)
|
||||
return "", fmt.Errorf("failed to download file from unsplash: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
tmpfile, err := ioutil.TempFile(l.tempDirProvider.TempDir(), picture.ID)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create temp file: %s", err)
|
||||
return "", fmt.Errorf("failed to create temp file: %w", err)
|
||||
}
|
||||
_, _ = io.Copy(tmpfile, resp.Body)
|
||||
tmpfile.Close()
|
||||
|
||||
err = injectIntoExif(tmpfile.Name(), picture.Artist, picture.ArtistURL, picture.Description)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to inject exif: %s", err)
|
||||
return "", fmt.Errorf("failed to inject exif: %w", err)
|
||||
}
|
||||
p, err := filepath.Abs(tmpfile.Name())
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to inject exif: %s", err)
|
||||
return "", fmt.Errorf("failed to inject exif: %w", err)
|
||||
}
|
||||
|
||||
go func(cl *unsplash.Unsplash) {
|
||||
|
@ -276,7 +276,7 @@ func injectIntoExif(filePath, artistName, artistUrl, description string) error {
|
|||
jmp := jpegstructure.NewJpegMediaParser()
|
||||
intfc, err := jmp.ParseFile(filePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open file to read exif: %s", err)
|
||||
return fmt.Errorf("failed to open file to read exif: %w", err)
|
||||
}
|
||||
sl := intfc.(*jpegstructure.SegmentList)
|
||||
rootIb, err := sl.ConstructExifBuilder()
|
||||
|
@ -295,11 +295,11 @@ func injectIntoExif(filePath, artistName, artistUrl, description string) error {
|
|||
f, err := os.OpenFile(filePath, os.O_RDWR|os.O_TRUNC, 0755)
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open file to write exif: %s", err)
|
||||
return fmt.Errorf("failed to open file to write exif: %w", err)
|
||||
}
|
||||
err = sl.Write(f)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write exif: %s", err)
|
||||
return fmt.Errorf("failed to write exif: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue