36 lines
831 B
Go
36 lines
831 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"time"
|
|
|
|
exceptionless "github.com/Exceptionless/Exceptionless.Go"
|
|
uuid "github.com/satori/go.uuid"
|
|
)
|
|
|
|
//SubmitError is a convenience wrapper to quickly build and submit an error
|
|
func submitError(err error) string {
|
|
referenceID := uuid.Must(uuid.NewV4())
|
|
errorMap := map[string]interface{}{}
|
|
errorMap["type"] = "error"
|
|
errorMap["message"] = err.Error()
|
|
errorMap["date"] = time.Now().Format(time.RFC3339)
|
|
|
|
data := map[string]interface{}{}
|
|
data["@simple_error"] = errorMap
|
|
var mainEvent = exceptionless.Event{
|
|
EventType: "error",
|
|
Message: err.Error(),
|
|
Data: data,
|
|
ReferenceID: referenceID,
|
|
}
|
|
json, err := json.Marshal(mainEvent)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return err.Error()
|
|
}
|
|
resp := exceptionless.SubmitEvent(string(json))
|
|
return resp
|
|
}
|