diff --git a/changelog.md b/changelog.md index b4f6e9a..cc3ef71 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ ## Changelog +#### v2.0.4 + +* Improved error handling + #### v2.0.3 * Global prefix feature removed diff --git a/librato.go b/librato.go index 728661f..b5200ff 100644 --- a/librato.go +++ b/librato.go @@ -23,7 +23,7 @@ import ( // ////////////////////////////////////////////////////////////////////////////////// // // VERSION contains current version of librato package and used as part of User-Agent -const VERSION = "2.0.3" +const VERSION = "2.0.4" // ////////////////////////////////////////////////////////////////////////////////// // @@ -655,6 +655,11 @@ func validateAnotation(a Annotation) error { func extractErrors(data string) []error { var err error + // Data doesn't looks like JSON. Return raw data + if !strings.HasPrefix(data, "{") { + return []error{fmt.Errorf(data)} + } + switch { case strings.Contains(data, "\"params\":"): errStruct := ¶msErrors{}