Skip to content

object:refactor data encode error #5426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions core/commands/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ import (
cid "gx/ipfs/QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb/go-cid"
)

// ErrObjectTooLarge is returned when too much data was read from stdin. current limit 2m
var ErrObjectTooLarge = errors.New("input object was too large. limit is 2mbytes")

const inputLimit = 2 << 20

type Node struct {
Expand All @@ -43,6 +40,8 @@ type Object struct {
Links []Link `json:"Links,omitempty"`
}

var ErrDataEncoding = errors.New("unkown data field encoding")

var ObjectCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Tagline: "Interact with IPFS objects.",
Expand Down Expand Up @@ -575,7 +574,7 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error)
}
dagnode.SetData(data)
default:
return nil, fmt.Errorf("unkown data field encoding")
return nil, ErrDataEncoding
}

links := make([]*ipld.Link, len(nd.Links))
Expand Down Expand Up @@ -617,5 +616,5 @@ func encodeData(data []byte, encoding string) (string, error) {
return base64.StdEncoding.EncodeToString(data), nil
}

return "", fmt.Errorf("unkown data field encoding")
return "", ErrDataEncoding
}