summaryrefslogtreecommitdiff
path: root/pkg/helpers/error.go
diff options
context:
space:
mode:
authorJulien Dessaux2024-11-17 00:05:22 +0100
committerJulien Dessaux2024-11-17 00:05:22 +0100
commit206182fcb9c4ab2b49e8e44c6a2711a988e3f968 (patch)
tree5cfc55047d833400028fb69a7f069f5cedecaacd /pkg/helpers/error.go
parentfix(tfstated): hash passwords instead of relying on the database encryption key (diff)
downloadtfstated-206182fcb9c4ab2b49e8e44c6a2711a988e3f968.tar.gz
tfstated-206182fcb9c4ab2b49e8e44c6a2711a988e3f968.tar.bz2
tfstated-206182fcb9c4ab2b49e8e44c6a2711a988e3f968.zip
chore(tfstated): refactored helpers to their own package
Diffstat (limited to 'pkg/helpers/error.go')
-rw-r--r--pkg/helpers/error.go17
1 files changed, 17 insertions, 0 deletions
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,
+ })
+}