aboutsummaryrefslogtreecommitdiff
path: root/errors.go
diff options
context:
space:
mode:
authorthinkpadmaster <a.scerba02@gmail.com>2023-07-13 23:34:25 -0500
committerthinkpadmaster <a.scerba02@gmail.com>2023-07-13 23:34:25 -0500
commite864807341990f5c72e198d96740983bf7671584 (patch)
treed0c9dd12da81272e7bd30cae4643bacdc030d47b /errors.go
parent8106f531198952489de53c93dd3c955e8ea4d78f (diff)
Move to multifile system and prepare for new file format
Diffstat (limited to 'errors.go')
-rw-r--r--errors.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/errors.go b/errors.go
new file mode 100644
index 0000000..9406a9a
--- /dev/null
+++ b/errors.go
@@ -0,0 +1,23 @@
+package main
+
+import (
+ "fmt"
+ "net/http"
+ "runtime/debug"
+)
+
+func (app *application) serverError(w http.ResponseWriter, err error) {
+ trace := fmt.Sprintf("%s\n%s", err.Error(), debug.Stack())
+ app.errorLog.Output(2, trace)
+
+ http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
+}
+
+func (app *application) clientError(w http.ResponseWriter, status int) {
+ app.errorLog.Printf("Clent error: %d\n", status)
+ http.Error(w, http.StatusText(status), status)
+}
+
+func (app *application) notFound(w http.ResponseWriter) {
+ app.clientError(w, http.StatusNotFound)
+}