You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-09-16 09:26:22 +02:00
feat(log): improve error message formatting by combining message and error details
This commit is contained in:
@@ -117,8 +117,18 @@ func (s *Splunk) prepareTelemetry(telemetryData telemetry.Data) MonitoringData {
|
|||||||
if fatalErrorDetail := log.GetFatalErrorDetail(); fatalErrorDetail != nil {
|
if fatalErrorDetail := log.GetFatalErrorDetail(); fatalErrorDetail != nil {
|
||||||
var errorDetail map[string]any
|
var errorDetail map[string]any
|
||||||
if err := json.Unmarshal(fatalErrorDetail, &errorDetail); err == nil {
|
if err := json.Unmarshal(fatalErrorDetail, &errorDetail); err == nil {
|
||||||
|
var parts []string
|
||||||
|
|
||||||
|
if messageVal, exists := errorDetail["message"]; exists && messageVal != nil {
|
||||||
|
parts = append(parts, fmt.Sprintf("%v", messageVal))
|
||||||
|
}
|
||||||
|
|
||||||
if errorVal, exists := errorDetail["error"]; exists && errorVal != nil {
|
if errorVal, exists := errorDetail["error"]; exists && errorVal != nil {
|
||||||
errorMessage = fmt.Sprintf("%v", errorVal)
|
parts = append(parts, fmt.Sprintf("%v", errorVal))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(parts) > 0 {
|
||||||
|
errorMessage = strings.Join(parts, " ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user