-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from willemschots/4-error-handling
4: Improve error handling
- Loading branch information
Showing
26 changed files
with
677 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ define "title" }}Something went wrong{{end}} | ||
|
||
{{define "body"}} | ||
|
||
<div class="w-full h-full bg-slate-100 flex flex-wrap justify-center items-start"> | ||
<div class="w-full"> | ||
{{ template "header" . }} | ||
</div> | ||
|
||
<div class="max-w-[480px] bg-slate-50 rounded-md shadow-md p-8"> | ||
<h1 class="text-2xl">Something went wrong</h1> | ||
</div> | ||
</div> | ||
|
||
{{end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{{ define "csrf-input" }} | ||
<input type="hidden" name="csrfToken" value="{{ .Global.CSRFToken }}"/> | ||
<input type="hidden" name="csrfToken" value="{{ .CSRFToken }}"/> | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{ define "input-errors" }} | ||
{{ if gt (len .InputErrors) 0 }} | ||
<div class="bg-red-100 px-2 py-1 text-red-700 rounded-md"> | ||
<p class="text-sm">Errors:</p> | ||
<ul class="pl-4 rounded-md list-disc"> | ||
{{ range .InputErrors }} | ||
<li>{{ . }}</li> | ||
{{ end }} | ||
</ul> | ||
</div> | ||
{{ end }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package errorz | ||
|
||
import "strings" | ||
|
||
// InvalidInput signals that a provided input is invalid due to the wrapped errors. | ||
type InvalidInput []error | ||
|
||
func (e InvalidInput) Error() string { | ||
var b strings.Builder | ||
b.WriteString("invalid input:\n") | ||
for _, err := range e { | ||
b.WriteString(err.Error()) | ||
b.WriteString("\n") | ||
} | ||
return b.String() | ||
} | ||
|
||
func (e InvalidInput) Unwrap() []error { | ||
return e | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package errorz | ||
|
||
type Keyed struct { | ||
Key string | ||
Err error | ||
} | ||
|
||
func (k Keyed) Error() string { | ||
return k.Key + ": " + k.Err.Error() | ||
} | ||
|
||
func (k Keyed) Unwrap() error { | ||
return k.Err | ||
} |
Oops, something went wrong.