Skip to content

Commit

Permalink
Bump up version of errs package
Browse files Browse the repository at this point in the history
  • Loading branch information
spiegel-im-spiegel committed Aug 12, 2020
1 parent 2556b04 commit 5159800
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 37 deletions.
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ builds:
- freebsd
goarch:
- amd64
- "386"
- arm
- arm64
main: ./cli/mklink/
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go

go:
- "1.13.x"
- "1.15.x"

env:
global:
Expand Down
10 changes: 5 additions & 5 deletions cli/mklink/facade/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ func interactiveMode(ui *rwi.RWI, cxt *makelink.Context) error {
}
buf := &bytes.Buffer{}
if _, err := io.Copy(buf, r); err != nil {
return "", errs.Wrap(err, "error when output result")
return "", errs.New("error when output result", errs.WithCause(err))
}
res := buf.String()
return res, errs.Wrap(clipboard.WriteAll(res), "error when output result")
return res, errs.Wrap(clipboard.WriteAll(res))
},
gprompt.WithPromptString("mklink> "),
gprompt.WithHeaderMessage("Input 'q' or 'quit' to stop"),
)
if !p.IsTerminal() {
return errs.Wrap(gprompt.ErrNotTerminal, "error in interactive mode")
return errs.Wrap(gprompt.ErrNotTerminal)
}
return errs.Wrap(p.Run(), "error in interactive mode")
return errs.Wrap(p.Run())
}

/* Copyright 2019 Spiegel
/* Copyright 2019,2020 Spiegel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
8 changes: 4 additions & 4 deletions cli/mklink/makelink/makelink.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ func New(s mklink.Style, log io.Writer) *Context {
//MakeLink is making link
func (c *Context) MakeLink(url string) (io.Reader, error) {
if c == nil {
return nil, errs.Wrap(mklink.ErrNullPointer, "reference error")
return nil, errs.New("reference error", errs.WithCause(mklink.ErrNullPointer))
}
lnk, err := mklink.New(url)
if err != nil {
return nil, errs.Wrap(err, "error in constructor")
return nil, errs.New("error in constructor", errs.WithCause(err))
}

rRes := lnk.Encode(c.linkStyle)
Expand All @@ -36,13 +36,13 @@ func (c *Context) MakeLink(url string) (io.Reader, error) {
}
buf := new(bytes.Buffer)
if _, err := io.Copy(c.log, io.TeeReader(rRes, buf)); err != nil {
return buf, errs.Wrap(err, "error in logging")
return buf, errs.New("error in logging", errs.WithCause(err))
}
fmt.Fprintln(c.log) //new line in logfile
return buf, nil
}

/* Copyright 2017-2019 Spiegel
/* Copyright 2017-2020 Spiegel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/spiegel-im-spiegel/mklink
go 1.13

require (
github.com/PuerkitoBio/goquery v1.5.0
github.com/PuerkitoBio/goquery v1.5.1
github.com/atotto/clipboard v0.1.2
github.com/mattn/go-encoding v0.0.2
github.com/spf13/cobra v0.0.5
github.com/spiegel-im-spiegel/errs v0.3.2
github.com/spf13/cobra v1.0.0
github.com/spiegel-im-spiegel/errs v1.0.0
github.com/spiegel-im-spiegel/gocli v0.10.1
github.com/spiegel-im-spiegel/gprompt v0.9.6
golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271
golang.org/x/net v0.0.0-20200707034311-ab3426394381
)
131 changes: 114 additions & 17 deletions go.sum

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions mklink.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func New(url string) (*Link, error) {
link := &Link{URL: trimString(url)}
resp, err := http.Get(url)
if err != nil {
return link, errs.Wrap(err, "Create mklink.Link instance")
return link, errs.New("Create mklink.Link instance", errs.WithCause(err))
}
defer resp.Body.Close()

Expand All @@ -49,7 +49,7 @@ func New(url string) (*Link, error) {
}
doc, err := goquery.NewDocumentFromReader(r)
if err != nil {
return link, errs.Wrap(err, "Create mklink.Link instance")
return link, errs.New("Create mklink.Link instance", errs.WithCause(err))
}

doc.Find("head").Each(func(_ int, s *goquery.Selection) {
Expand Down Expand Up @@ -90,7 +90,7 @@ func (lnk *Link) JSON() (io.Reader, error) {
encoder := json.NewEncoder(buf)
encoder.SetIndent("", " ")
if err := encoder.Encode(lnk); err != nil {
return ioutil.NopCloser(bytes.NewReader(nil)), errs.Wrap(err, "error in encoding JSON")
return ioutil.NopCloser(bytes.NewReader(nil)), errs.New("error in encoding JSON", errs.WithCause(err))
}
return buf, nil
}
Expand Down Expand Up @@ -136,7 +136,7 @@ func (lnk *Link) String() string {
return fmt.Sprint(r)
}

/* Copyright 2017-2019 Spiegel
/* Copyright 2017-2020 Spiegel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion style.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func GetStyle(s string) (Style, error) {
return t, nil
}
}
return StyleUnknown, errs.Wrap(ErrNoImplement, "", errs.WithContext("style", s))
return StyleUnknown, errs.Wrap(ErrNoImplement, errs.WithContext("style", s))
}

func (t Style) String() string {
Expand Down

0 comments on commit 5159800

Please sign in to comment.