Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#137 #50

Merged
merged 1 commit into from Jun 12, 2022
Merged

#137 #50

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions main.go
Expand Up @@ -32,7 +32,7 @@ func showHTML(w http.ResponseWriter, r *http.Request) {

data, err := os.ReadFile("index.html")
if err != nil {
RespondInternalServerError(w)
RespondInternalServerError(w, err.Error())
return
}

Expand Down Expand Up @@ -140,7 +140,7 @@ func addMemo(w http.ResponseWriter, r *http.Request) {
//HTTPリクエストで送信されてきた HTTP Request Body(JSON形式)を
//Memo構造体にセットしている。
if err := json.NewDecoder(r.Body).Decode(m); err != nil {
RespondInternalServerError(w)
RespondInternalServerError(w, err.Error())
return
}

Expand All @@ -164,7 +164,8 @@ func addMemo(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, len(memos))
}

func RespondInternalServerError(w http.ResponseWriter) {
func RespondInternalServerError(w http.ResponseWriter, errorLogMessage string) {
ErrorLog(errorLogMessage)
RespondError(
w,
http.StatusInternalServerError,
Expand Down Expand Up @@ -211,7 +212,7 @@ func listMemos(w http.ResponseWriter, r *http.Request) {

b, err := json.Marshal(memos)
if err != nil {
RespondInternalServerError(w)
RespondInternalServerError(w, err.Error())
return

}
Expand Down Expand Up @@ -314,7 +315,7 @@ func NewBaselogError() *BaseLog {

//エラーログ
//ログレベル = Error
//用途 = サーバ側でエラーが発生したときに利用する
//用途 = サーバ側でエラーが発生したときに利用する(サーバが悪い)
func ErrorLog(message string) {
j, _ := json.Marshal(NewLogError(message))
log.Print(string(j))
Expand Down