You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
549 B
Go
22 lines
549 B
Go
1 year ago
|
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) {
|
||
|
http.Error(w, http.StatusText(status), status)
|
||
|
}
|
||
|
|
||
|
func (app *application) notFound(w http.ResponseWriter) {
|
||
|
app.clientError(w, http.StatusNotFound)
|
||
|
}
|