Skip to content

Commit 1a6a8c2

Browse files
Refactor error package (#804)
* refactor errors package * use refactored errors * refactor log entry * Update logs.go * refactor errors * fix doc logo * fix stringify error * update github actions * Update build.yml * Update build.yml * fix test * fix wrapping format
1 parent 6b8f600 commit 1a6a8c2

39 files changed

+1613
-860
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Setup Go
11-
uses: actions/setup-go@v2
11+
uses: actions/setup-go@v3
1212
with:
1313
go-version: "1.18"
1414
- name: Checkout Code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v3
1616
- name: Vet
1717
run: go vet ./...
1818

@@ -21,24 +21,24 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Setup Go
24-
uses: actions/setup-go@v2
24+
uses: actions/setup-go@v3
2525
with:
2626
go-version: "1.18"
2727
- name: Checkout Code
28-
uses: actions/checkout@v2
28+
uses: actions/checkout@v3
2929
- name: Run Unit Tests
30-
run: go test -v -race ./...
30+
run: go test -race ./...
3131

3232
client:
3333
name: WebAssembly Unit Tests
3434
runs-on: ubuntu-latest
3535
steps:
3636
- name: Setup Go
37-
uses: actions/setup-go@v2
37+
uses: actions/setup-go@v3
3838
with:
3939
go-version: "1.18"
4040
- name: Checkout Code
41-
uses: actions/checkout@v2
41+
uses: actions/checkout@v3
4242
- name: Install WASM Browser Test
4343
run: |
4444
go install github.com/agnivade/wasmbrowsertest@latest

docs/icon.png

34.7 KB
Loading

docs/src/home-page.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (p *homePage) initPage(ctx app.Context) {
3131
func (p *homePage) Render() app.UI {
3232
return newPage().
3333
Title("go-app").
34-
Icon("https://storage.googleapis.com/murlok-github/icon-192.png").
34+
Icon("/web/icon.png").
3535
Index(
3636
newIndexLink().Title("What is go-app?"),
3737
newIndexLink().Title("Updates"),

docs/src/http.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ func get(ctx app.Context, path string) ([]byte, error) {
2020
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
2121
if err != nil {
2222
return nil, errors.New("creating request failed").
23-
Tag("path", path).
23+
WithTag("path", path).
2424
Wrap(err)
2525
}
2626

2727
res, err := http.DefaultClient.Do(req)
2828
if err != nil {
2929
return nil, errors.New("getting document failed").
30-
Tag("path", path).
30+
WithTag("path", path).
3131
Wrap(err)
3232
}
3333
defer res.Body.Close()
3434

3535
if res.StatusCode >= 400 {
36-
return nil, errors.New(res.Status).Tag("path", path)
36+
return nil, errors.New(res.Status).WithTag("path", path)
3737
}
3838

3939
b, err := ioutil.ReadAll(res.Body)
4040
if err != nil {
4141
return nil, errors.New("reading document failed").
42-
Tag("path", path).
42+
WithTag("path", path).
4343
Wrap(err)
4444
}
4545
return b, nil

docs/src/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ func main() {
103103
Description: defaultDescription,
104104
Author: "Maxence Charriere",
105105
Image: "https://go-app.dev/web/images/go-app.png",
106+
Icon: app.Icon{
107+
Default: "/web/icon.png",
108+
},
106109
Keywords: []string{
107110
"go-app",
108111
"go",
@@ -158,8 +161,8 @@ func main() {
158161

159162
func runLocal(ctx context.Context, h *app.Handler, opts localOptions) {
160163
app.Log(logs.New("starting go-app documentation service").
161-
Tag("port", opts.Port).
162-
Tag("version", h.Version),
164+
WithTag("port", opts.Port).
165+
WithTag("version", h.Version),
163166
)
164167

165168
h.Env = app.Environment{

docs/src/markdown.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func handleGetMarkdown(ctx app.Context, a app.Action) {
1313
path := a.Tags.Get("path")
1414
if path == "" {
1515
app.Log(errors.New("getting markdown failed").
16-
Tag("reason", "empty path"))
16+
WithTag("reason", "empty path"))
1717
return
1818
}
1919
state := markdownState(path)

docs/src/reference.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func getHTML(n *html.Node, class string) (string, error) {
8282
section, err := findHTMLNode(n, class)
8383
if err != nil {
8484
return "", errors.New("finding html node failed").
85-
Tag("target", class).
85+
WithTag("target", class).
8686
Wrap(err)
8787
}
8888

@@ -91,7 +91,7 @@ func getHTML(n *html.Node, class string) (string, error) {
9191
var b bytes.Buffer
9292
if err := html.Render(&b, section); err != nil {
9393
return "", errors.New("rendering html failed").
94-
Tag("target", class).
94+
WithTag("target", class).
9595
Wrap(err)
9696
}
9797
return b.String(), nil

docs/web/app.wasm

64.5 KB
Binary file not shown.

docs/web/documents/reference.html

Lines changed: 864 additions & 250 deletions
Large diffs are not rendered by default.

docs/web/icon.png

34.7 KB
Loading

0 commit comments

Comments
 (0)