A simple and efficient package to handle staging and production errors.
go get github.com/Alvarios/watcher
You need a Slack application that supports incoming webhooks.
Create a SlackConfig in your go code.
package myPackage
import "github.com/Alvarios/watcher"
var Watcher watcher.SlackConfig
func main() {
Watcher := watcher.SlackConfig{
WebHook: "https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX",
Application: "Your application name",
}
}
Send a basic error message to Slack.
package myPackage
func MyFunction() {
_, err := Watcher.Error("some error message")
}
Same as Error method, but kills the running server and doesn't return any status.
package myPackage
func MyFunction() {
Watcher.Fatal("some fatal message")
}
A special message formatter for Gin, that also interrupts the request.
package myPackage
import "github.com/gin-gonic/gin"
func MyMiddleware(c *gin.Context) {
Watcher.GinAbort(c, "some error message")
}
2020 Kushuh - MIT license