Skip to content

Commit

Permalink
remove errors.WithStack (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Apr 5, 2019
1 parent d661241 commit 9ac46fa
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 71 deletions.
96 changes: 48 additions & 48 deletions compiler.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions content_helper.go
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
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
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
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
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
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
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
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

0 comments on commit 9ac46fa

Please sign in to comment.