Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

take on errx #1725

Merged
merged 3 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion binding/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"sync"
"time"

"github.com/gobuffalo/nulls"
"github.com/gobuffalo/buffalo/internal/httpx"
"github.com/gobuffalo/nulls"
"github.com/monoculum/formam"
)

Expand Down
2 changes: 1 addition & 1 deletion buffalo/cmd/fix/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"

"github.com/gobuffalo/buffalo/genny/plugins/install"
"github.com/gobuffalo/buffalo/internal/errx"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/plugins"
"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/genny"
Expand Down
2 changes: 1 addition & 1 deletion buffalo/cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/gobuffalo/buffalo/genny/newapp/web"
"github.com/gobuffalo/buffalo/genny/refresh"
"github.com/gobuffalo/buffalo/genny/vcs"
"github.com/gobuffalo/buffalo/internal/errx"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/envy"
fname "github.com/gobuffalo/flect/name"
"github.com/gobuffalo/genny"
Expand Down
2 changes: 1 addition & 1 deletion buffalo/cmd/plugins/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/gobuffalo/buffalo/genny/add"
"github.com/gobuffalo/buffalo/internal/errx"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/meta"
Expand Down
2 changes: 1 addition & 1 deletion buffalo/cmd/plugins/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"github.com/gobuffalo/buffalo/genny/plugins/install"
"github.com/gobuffalo/buffalo/internal/errx"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/logger"
Expand Down
2 changes: 1 addition & 1 deletion buffalo/cmd/plugins/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"path"
"strings"

"github.com/gobuffalo/buffalo/internal/errx"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/meta"
Expand Down
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"sync"

"github.com/gobuffalo/buffalo/binding"
"github.com/gobuffalo/buffalo/render"
"github.com/gobuffalo/buffalo/internal/httpx"
"github.com/gobuffalo/buffalo/render"
"github.com/gorilla/mux"
)

Expand Down
2 changes: 1 addition & 1 deletion default_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"time"

"github.com/gobuffalo/buffalo/binding"
"github.com/gobuffalo/buffalo/internal/errx"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/render"
)

Expand Down
3 changes: 1 addition & 2 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"strings"

"github.com/gobuffalo/buffalo/internal/defaults"
"github.com/gobuffalo/buffalo/internal/errx"
"github.com/gobuffalo/buffalo/internal/httpx"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/events"
"github.com/gobuffalo/plush"
)
Expand Down Expand Up @@ -168,7 +168,6 @@ func defaultErrorHandler(status int, origErr error, c Context) error {
c.Response().Write(responseBody)
return nil
}

trace := origErr.Error()
switch strings.ToLower(requestCT) {
case "application/json", "text/json", "json":
Expand Down
12 changes: 11 additions & 1 deletion genny/actions/actions_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package actions

import (
"fmt"
"strings"
"testing"

"github.com/gobuffalo/genny"
"github.com/gobuffalo/genny/gentest"
packr "github.com/gobuffalo/packr/v2"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
)

Expand All @@ -15,7 +17,13 @@ func compare(a, b string) bool {
a = strings.Replace(a, "\r", "", -1)
b = strings.TrimSpace(b)
b = strings.Replace(b, "\r", "", -1)
return a == b
a = strings.TrimSpace(a)
b = strings.TrimSpace(b)
res := cmp.Equal(a, b)
if !res {
fmt.Println(cmp.Diff(a, b))
}
return res
}

func runner() *genny.Runner {
Expand Down Expand Up @@ -52,6 +60,8 @@ func Test_New(t *testing.T) {
r.NoError(err)
f, err := res.Find(strings.TrimSuffix(s, ".tmpl"))
r.NoError(err)
fmt.Println(x)
fmt.Println(f.String())
r.True(compare(x, f.String()))
}
}
Expand Down
2 changes: 1 addition & 1 deletion genny/add/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package add
import (
"os"

"github.com/gobuffalo/buffalo/internal/errx"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/meta"
)
Expand Down
2 changes: 1 addition & 1 deletion genny/build/build_deps.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package build

import (
"github.com/gobuffalo/genny/depgen"
"github.com/gobuffalo/envy"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/genny/depgen"
"github.com/gobuffalo/genny/gogen"
)

Expand Down
6 changes: 3 additions & 3 deletions genny/newapp/core/core.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package core

import (
"github.com/gobuffalo/buffalo/genny/docker"
pop "github.com/gobuffalo/buffalo-pop/genny/newapp"
"github.com/gobuffalo/buffalo/genny/ci"
"github.com/gobuffalo/buffalo/genny/docker"
"github.com/gobuffalo/buffalo/genny/plugins/install"
"github.com/gobuffalo/buffalo/genny/refresh"
"github.com/gobuffalo/buffalo/internal/errx"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/buffalo/runtime"
"github.com/gobuffalo/genny/depgen"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/genny/depgen"
"github.com/gobuffalo/genny/gogen"
"github.com/gobuffalo/genny/gogen/gomods"
"github.com/gobuffalo/meta"
Expand Down
2 changes: 1 addition & 1 deletion genny/newapp/core/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"regexp"
"strings"

"github.com/gobuffalo/buffalo/genny/docker"
"github.com/gobuffalo/buffalo-pop/genny/newapp"
"github.com/gobuffalo/buffalo/genny/ci"
"github.com/gobuffalo/buffalo/genny/docker"
"github.com/gobuffalo/buffalo/genny/refresh"
"github.com/gobuffalo/buffalo/genny/vcs"
"github.com/gobuffalo/buffalo/runtime"
Expand Down
2 changes: 1 addition & 1 deletion genny/plugins/install/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package install
import (
"os"

"github.com/gobuffalo/buffalo/internal/errx"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/meta"
)
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/dustin/go-humanize v1.0.0
github.com/fatih/color v1.7.0
github.com/gobuffalo/attrs v0.1.0
github.com/gobuffalo/buffalo-pop v1.15.0
github.com/gobuffalo/buffalo-pop v1.16.0
github.com/gobuffalo/clara v0.7.0
github.com/gobuffalo/envy v1.7.0
github.com/gobuffalo/events v1.4.0
Expand All @@ -25,10 +25,10 @@ require (
github.com/gobuffalo/packd v0.3.0
github.com/gobuffalo/packr/v2 v2.5.2
github.com/gobuffalo/plush v3.8.2+incompatible
github.com/gobuffalo/pop v4.11.1+incompatible
github.com/gobuffalo/pop v4.11.2+incompatible
github.com/gobuffalo/release v1.8.3
github.com/gobuffalo/tags v2.1.0+incompatible
github.com/gobuffalo/x v0.1.0 // indirect
github.com/google/go-cmp v0.3.0
github.com/gorilla/mux v1.7.3
github.com/gorilla/sessions v1.1.3
github.com/karrick/godirwalk v1.10.12
Expand All @@ -46,7 +46,7 @@ require (
github.com/spf13/viper v1.4.0
github.com/stretchr/testify v1.3.0
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/tools v0.0.0-20190702152245-7e72c71c505f
golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc
gopkg.in/yaml.v2 v2.2.2
)
17 changes: 8 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ github.com/gobuffalo/buffalo-pop v1.9.0/go.mod h1:MfrkBg0iN9+RdlxdHHAqqGFAC/iyCf
github.com/gobuffalo/buffalo-pop v1.10.0/go.mod h1:C3/cFXB8Zd38XiGgHFdE7dw3Wu9MOKeD7bfELQicGPI=
github.com/gobuffalo/buffalo-pop v1.12.0/go.mod h1:pO2ONSJOCjyroGp4BwVHfMkfd7sLg1U9BvMJqRy6Otk=
github.com/gobuffalo/buffalo-pop v1.13.0/go.mod h1:h+zfyXCUFwihFqz6jmo9xsdsZ1Tm9n7knYpQjW0gv18=
github.com/gobuffalo/buffalo-pop v1.15.0 h1:tk8F1C4O/ibGN46CGrbj01cqwucXBRJd8guawhW67MY=
github.com/gobuffalo/buffalo-pop v1.15.0/go.mod h1:4r1aTrLpQWFSlea6wIDCUb/gZ7jr2DJuS4J80A+LBhE=
github.com/gobuffalo/buffalo-pop v1.16.0 h1:3TGHkwhMIElpy8K+E5tPM5rUo9tG5JxRXfiz/M9ZrPE=
github.com/gobuffalo/buffalo-pop v1.16.0/go.mod h1:XYA72cNFvL6m1o7PZ+Z7Yd/WDQTPcOiuDukiHvEo2KY=
github.com/gobuffalo/clara v0.4.1/go.mod h1:3QgAPqYgPqAzhfGbNLlp4UztaZRi2SOg+ZrZwaq9L94=
github.com/gobuffalo/clara v0.6.0/go.mod h1:RKZxkcH80pLykRi2hLkoxGMxA8T06Dc9fN/pFvutMFY=
github.com/gobuffalo/clara v0.7.0 h1:0amX0tIW8NtyItI9QND0jy7ja0jaNMfMXNlDlznYpA4=
Expand Down Expand Up @@ -251,7 +251,6 @@ github.com/gobuffalo/gogen v0.0.0-20190224213239-1c6076128bbc/go.mod h1:tQqPADZK
github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360=
github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg=
github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE=
github.com/gobuffalo/gogen v0.2.0 h1:Xx7NCe+/y++eII2aWAFZ09/81MhDCsZwvMzIFJoQRnU=
github.com/gobuffalo/gogen v0.2.0/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360=
github.com/gobuffalo/helpers v0.0.0-20190422082217-384f90c6579f/go.mod h1:g0I3qKQEyJxwnHtEmLugD75eoOiWxEtibcV62tYah9w=
github.com/gobuffalo/helpers v0.0.0-20190506214229-8e6f634af7c3/go.mod h1:HlNpmw2+Rjx882VUf6hJfNJs5wpNRzX02KcqCXDlLGc=
Expand Down Expand Up @@ -430,8 +429,9 @@ github.com/gobuffalo/pop v4.9.8+incompatible/go.mod h1:DwBz3SD5SsHpTZiTubcsFWcVD
github.com/gobuffalo/pop v4.9.9+incompatible/go.mod h1:DwBz3SD5SsHpTZiTubcsFWcVDpJWGsxjVjMPnkiThWg=
github.com/gobuffalo/pop v4.10.0+incompatible/go.mod h1:DwBz3SD5SsHpTZiTubcsFWcVDpJWGsxjVjMPnkiThWg=
github.com/gobuffalo/pop v4.11.0+incompatible/go.mod h1:DwBz3SD5SsHpTZiTubcsFWcVDpJWGsxjVjMPnkiThWg=
github.com/gobuffalo/pop v4.11.1+incompatible h1:WPaOpbIZZpOz0hcIF1trnYgC3FivQSTWSRXf/fTUjYc=
github.com/gobuffalo/pop v4.11.1+incompatible/go.mod h1:DwBz3SD5SsHpTZiTubcsFWcVDpJWGsxjVjMPnkiThWg=
github.com/gobuffalo/pop v4.11.2+incompatible h1:yohroCWPJDiarrFtB79XrCiCK0MAu2dpzbXFFv3bnuM=
github.com/gobuffalo/pop v4.11.2+incompatible/go.mod h1:DwBz3SD5SsHpTZiTubcsFWcVDpJWGsxjVjMPnkiThWg=
github.com/gobuffalo/release v1.0.35/go.mod h1:VtHFAKs61vO3wboCec5xr9JPTjYyWYcvaM3lclkc4x4=
github.com/gobuffalo/release v1.0.38/go.mod h1:VtHFAKs61vO3wboCec5xr9JPTjYyWYcvaM3lclkc4x4=
github.com/gobuffalo/release v1.0.42/go.mod h1:RPs7EtafH4oylgetOJpGP0yCZZUiO4vqHfTHJjSdpug=
Expand Down Expand Up @@ -479,8 +479,6 @@ github.com/gobuffalo/x v0.0.0-20181025192250-1ef645d63fe8/go.mod h1:AIlnMGlYXOCs
github.com/gobuffalo/x v0.0.0-20181109195216-5b3131238124/go.mod h1:GpdLUY6/Ztf/3FfxfwsLkDqAGZ0brhlh7LzIibHyZp0=
github.com/gobuffalo/x v0.0.0-20181110221217-14085ca3e1a9/go.mod h1:ig5vdn4+5IPtxgESlZWo1SSDyHKKef8EjVVKhY9kkIQ=
github.com/gobuffalo/x v0.0.0-20190224155809-6bb134105960/go.mod h1:ig5vdn4+5IPtxgESlZWo1SSDyHKKef8EjVVKhY9kkIQ=
github.com/gobuffalo/x v0.1.0 h1:ILV6PIfyQto7RKfxRutQUuW234x+A5/+FRQpik0hNrM=
github.com/gobuffalo/x v0.1.0/go.mod h1:WevpGD+5YOreDJznWevcn8NTmQEW5STSBgIkpkjzqXc=
github.com/gofrs/uuid v3.1.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
Expand All @@ -499,6 +497,8 @@ github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
Expand Down Expand Up @@ -579,7 +579,6 @@ github.com/markbates/deplist v1.2.0/go.mod h1:dtsWLZ5bWoazbM0rCxZncQaAPifWbvHgBJ
github.com/markbates/deplist v1.3.0 h1:uPgoloPraPBPYtNSxj2UwZBh2EHW9TmMvQCP2FBiRlU=
github.com/markbates/deplist v1.3.0/go.mod h1:dtsWLZ5bWoazbM0rCxZncQaAPifWbvHgBJk8UNI1Yfk=
github.com/markbates/going v1.0.2/go.mod h1:UWCk3zm0UKefHZ7l8BNqi26UyiEMniznk8naLdTcy6c=
github.com/markbates/going v1.0.3 h1:mY45T5TvW+Xz5A6jY7lf4+NLg9D8+iuStIHyR7M8qsE=
github.com/markbates/going v1.0.3/go.mod h1:fQiT6v6yQar9UD6bd/D4Z5Afbk9J6BBVBtLiyY4gp2o=
github.com/markbates/grift v1.0.4/go.mod h1:wbmtW74veyx+cgfwFhlnnMWqhoz55rnHR47oMXzsyVs=
github.com/markbates/grift v1.0.5/go.mod h1:EHmVIjOQoj/OOBDzlZ8RW0ZkvOtQ4xRHjrPvmfoiFaU=
Expand Down Expand Up @@ -948,8 +947,8 @@ golang.org/x/tools v0.0.0-20190613204242-ed0dc450797f/go.mod h1:/rFqwRUd4F7ZHNgw
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190702152245-7e72c71c505f h1:XuMNpyHOxIlwKrTVJPoK2xNLzWCoLJeMHVN8N7ctzgw=
golang.org/x/tools v0.0.0-20190702152245-7e72c71c505f/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db h1:9hRk1xeL9LTT3yX/941DqeBz87XgHAQuj+TbimYJuiw=
golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y=
Expand Down
21 changes: 0 additions & 21 deletions internal/errx/errors.go

This file was deleted.

21 changes: 21 additions & 0 deletions internal/takeon/github.com/markbates/errx/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 Mark Bates

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
49 changes: 49 additions & 0 deletions internal/takeon/github.com/markbates/errx/errx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package errx

import "fmt"

// go2 errors
type Wrapper interface {
Unwrap() error
}

// pkg/errors
type Causer interface {
Cause() error
}

func Unwrap(err error) error {
switch e := err.(type) {
case Wrapper:
return e.Unwrap()
case Causer:
return e.Cause()
}
return err
}

var Cause = Unwrap

func Wrap(err error, msg string) error {
return wrapped{
err: err,
msg: msg,
}
}

type wrapped struct {
err error
msg string
}

func (w wrapped) Error() string {
return fmt.Sprintf("%s: %s", w.msg, w.err)
}

func (w wrapped) Unwrap() error {
return w.err
}

func (w wrapped) Cause() error {
return w.err
}
4 changes: 4 additions & 0 deletions internal/takeon/github.com/markbates/errx/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package errx

// Version of errx
const Version = "v1.1.0"
Loading