Skip to content
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

remove errors.WithStack #91

Merged
merged 2 commits into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
96 changes: 48 additions & 48 deletions compiler.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions content_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func contentForHelper(name string, help HelperContext) {
}
body, err := help.BlockWith(ctx)
if err != nil {
return "", errors.WithStack(err)
return "", err
}
return template.HTML(body), nil
})
Expand All @@ -39,7 +39,7 @@ func contentOfHelper(name string, data map[string]interface{}, help HelperContex
fn, ok := help.Value("contentFor:" + name).(func(data map[string]interface{}) (template.HTML, error))
if !ok {
if !help.HasBlock() {
return template.HTML(""), errors.WithStack(errors.New("missing contentOf block: " + name))
return template.HTML(""), errors.New("missing contentOf block: " + name)
}

ctx := help.New()
Expand All @@ -48,7 +48,7 @@ func contentOfHelper(name string, data map[string]interface{}, help HelperContex
}
body, err := help.BlockWith(ctx)
if err != nil {
return template.HTML(""), errors.WithStack(err)
return template.HTML(""), err
}

return template.HTML(body), nil
Expand Down
6 changes: 2 additions & 4 deletions helper_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package plush

import (
"sync"

"github.com/pkg/errors"
)

// HelperMap holds onto helpers and validates they are properly formed.
Expand All @@ -21,7 +19,7 @@ func NewHelperMap() (HelperMap, error) {

err := hm.AddMany(Helpers.Helpers())
if err != nil {
return hm, errors.WithStack(err)
return hm, err
}
return hm, nil
}
Expand All @@ -43,7 +41,7 @@ func (h *HelperMap) AddMany(helpers map[string]interface{}) error {
for k, v := range helpers {
err := h.Add(k, v)
if err != nil {
return errors.WithStack(err)
return err
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (h HelperContext) BlockWith(ctx *Context) (string, error) {
func toJSONHelper(v interface{}) (template.HTML, error) {
b, err := json.Marshal(v)
if err != nil {
return "", errors.WithStack(err)
return "", err
}
return template.HTML(b), nil
}
Expand Down
4 changes: 2 additions & 2 deletions iterators.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func untilHelper(a int) Iterator {

func groupByHelper(size int, underlying interface{}) (*groupBy, error) {
if size <= 0 {
return nil, errors.WithStack(errors.New("size must be greater than zero"))
return nil, errors.New("size must be greater than zero")
}
u := reflect.Indirect(reflect.ValueOf(underlying))

Expand Down Expand Up @@ -66,7 +66,7 @@ func groupByHelper(size int, underlying interface{}) (*groupBy, error) {
pos += groupSize
}
default:
return nil, errors.WithStack(errors.Errorf("can not use %T in groupBy", underlying))
return nil, errors.Errorf("can not use %T in groupBy", underlying)
}
g := &groupBy{
group: group,
Expand Down
8 changes: 3 additions & 5 deletions plush.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"io"
"io/ioutil"
"sync"

"github.com/pkg/errors"
)

// DefaultTimeFormat is the default way of formatting a time.Time type.
Expand Down Expand Up @@ -54,7 +52,7 @@ func Parse(input string) (*Template, error) {
}

if err != nil {
return t, errors.WithStack(err)
return t, err
}

return t, nil
Expand All @@ -64,15 +62,15 @@ func Parse(input string) (*Template, error) {
func Render(input string, ctx *Context) (string, error) {
t, err := Parse(input)
if err != nil {
return "", errors.WithStack(err)
return "", err
}
return t.Exec(ctx)
}

func RenderR(input io.Reader, ctx *Context) (string, error) {
b, err := ioutil.ReadAll(input)
if err != nil {
return "", errors.WithStack(err)
return "", err
}
return Render(string(b), ctx)
}
Expand Down
4 changes: 2 additions & 2 deletions plush/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ var RootCmd = &cobra.Command{
for _, a := range args {
b, err := ioutil.ReadFile(a)
if err != nil {
return errors.WithStack(err)
return err
}
err = plush.RunScript(string(b), plush.NewContext())
if err != nil {
return errors.WithStack(err)
return err
}

}
Expand Down
6 changes: 2 additions & 4 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"github.com/gobuffalo/plush/ast"

"github.com/gobuffalo/plush/parser"

"github.com/pkg/errors"
)

// Template represents an input and helpers to be used
Expand All @@ -24,7 +22,7 @@ func NewTemplate(input string) (*Template, error) {
}
err := t.Parse()
if err != nil {
return t, errors.WithStack(err)
return t, err
}
return t, nil
}
Expand All @@ -38,7 +36,7 @@ func (t *Template) Parse() error {
}
program, err := parser.Parse(t.Input)
if err != nil {
return errors.WithStack(err)
return err
}
t.program = program
return nil
Expand Down
3 changes: 1 addition & 2 deletions variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"

"github.com/gobuffalo/tags"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -46,7 +45,7 @@ func Test_Let_Inside_Helper(t *testing.T) {
"divwrapper": func(opts map[string]interface{}, helper HelperContext) (template.HTML, error) {
body, err := helper.Block()
if err != nil {
return template.HTML(""), errors.WithStack(err)
return template.HTML(""), err
}
t := tags.New("div", opts)
t.Append(body)
Expand Down