From 206182fcb9c4ab2b49e8e44c6a2711a988e3f968 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 17 Nov 2024 00:05:22 +0100 Subject: chore(tfstated): refactored helpers to their own package --- pkg/helpers/error.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 pkg/helpers/error.go (limited to 'pkg/helpers/error.go') diff --git a/pkg/helpers/error.go b/pkg/helpers/error.go new file mode 100644 index 0000000..006759d --- /dev/null +++ b/pkg/helpers/error.go @@ -0,0 +1,17 @@ +package helpers + +import ( + "fmt" + "net/http" +) + +func ErrorResponse(w http.ResponseWriter, status int, err error) { + type errorResponse struct { + Msg string `json:"msg"` + Status int `json:"status"` + } + _ = Encode(w, status, &errorResponse{ + Msg: fmt.Sprintf("%+v", err), + Status: status, + }) +} -- cgit v1.2.3