summaryrefslogtreecommitdiff
path: root/internal/ap/resolve.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-06-27 11:37:42 +0200
committerLibravatar GitHub <noreply@github.com>2023-06-27 11:37:42 +0200
commitd98b6318ace5f8a00a6d1776be2e78782f7eb429 (patch)
treed10ce092258e0db0c57b063483fe4ca7e307ce46 /internal/ap/resolve.go
parent[chore]: Bump github.com/minio/minio-go/v7 from 7.0.56 to 7.0.58 (#1928) (diff)
downloadgotosocial-d98b6318ace5f8a00a6d1776be2e78782f7eb429.tar.xz
[bugfix] Use gtserror package for WrongType errs (#1930)
* [bugfix] Use gtserror package for WrongType errs * test
Diffstat (limited to 'internal/ap/resolve.go')
-rw-r--r--internal/ap/resolve.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/ap/resolve.go b/internal/ap/resolve.go
index ef4d0b50f..a9955be3f 100644
--- a/internal/ap/resolve.go
+++ b/internal/ap/resolve.go
@@ -20,10 +20,10 @@ package ap
import (
"context"
"encoding/json"
- "fmt"
"github.com/superseriousbusiness/activity/streams"
"github.com/superseriousbusiness/activity/streams/vocab"
+ "github.com/superseriousbusiness/gotosocial/internal/gtserror"
)
// ResolveStatusable tries to resolve the given bytes into an ActivityPub Statusable representation.
@@ -33,12 +33,12 @@ import (
func ResolveStatusable(ctx context.Context, b []byte) (Statusable, error) {
rawStatusable := make(map[string]interface{})
if err := json.Unmarshal(b, &rawStatusable); err != nil {
- return nil, fmt.Errorf("ResolveStatusable: error unmarshalling bytes into json: %w", err)
+ return nil, gtserror.Newf("error unmarshalling bytes into json: %w", err)
}
t, err := streams.ToType(ctx, rawStatusable)
if err != nil {
- return nil, fmt.Errorf("ResolveStatusable: error resolving json into ap vocab type: %w", err)
+ return nil, gtserror.Newf("error resolving json into ap vocab type: %w", err)
}
var (
@@ -68,8 +68,8 @@ func ResolveStatusable(ctx context.Context, b []byte) (Statusable, error) {
}
if !ok {
- err = fmt.Errorf("ResolveStatusable: could not resolve %T to Statusable", t)
- return nil, newErrWrongType(err)
+ err = gtserror.Newf("could not resolve %T to Statusable", t)
+ return nil, gtserror.SetWrongType(err)
}
NormalizeIncomingContent(statusable, rawStatusable)
@@ -87,12 +87,12 @@ func ResolveStatusable(ctx context.Context, b []byte) (Statusable, error) {
func ResolveAccountable(ctx context.Context, b []byte) (Accountable, error) {
rawAccountable := make(map[string]interface{})
if err := json.Unmarshal(b, &rawAccountable); err != nil {
- return nil, fmt.Errorf("ResolveAccountable: error unmarshalling bytes into json: %w", err)
+ return nil, gtserror.Newf("error unmarshalling bytes into json: %w", err)
}
t, err := streams.ToType(ctx, rawAccountable)
if err != nil {
- return nil, fmt.Errorf("ResolveAccountable: error resolving json into ap vocab type: %w", err)
+ return nil, gtserror.Newf("error resolving json into ap vocab type: %w", err)
}
var (
@@ -114,8 +114,8 @@ func ResolveAccountable(ctx context.Context, b []byte) (Accountable, error) {
}
if !ok {
- err = fmt.Errorf("ResolveAccountable: could not resolve %T to Accountable", t)
- return nil, newErrWrongType(err)
+ err = gtserror.Newf("could not resolve %T to Accountable", t)
+ return nil, gtserror.SetWrongType(err)
}
NormalizeIncomingSummary(accountable, rawAccountable)