Error implements the error interface
()
| 106 | |
| 107 | // Error implements the error interface |
| 108 | func (e *OperationError) Error() string { |
| 109 | var b strings.Builder |
| 110 | |
| 111 | fmt.Fprintf(&b, "[%s] Failed to %s %s", |
| 112 | e.Timestamp.Format(time.RFC3339), e.Operation, e.EntityType) |
| 113 | |
| 114 | if e.EntityID != "" { |
| 115 | fmt.Fprintf(&b, " #%s", e.EntityID) |
| 116 | } |
| 117 | |
| 118 | if e.Cause != nil { |
| 119 | fmt.Fprintf(&b, "\n\nUnderlying error: %v", e.Cause) |
| 120 | } |
| 121 | |
| 122 | if e.Suggestion != "" { |
| 123 | fmt.Fprintf(&b, "\nSuggestion: %s", e.Suggestion) |
| 124 | } else { |
| 125 | // Provide default suggestion |
| 126 | fmt.Fprintf(&b, "\nSuggestion: Check that the %s exists and you have the necessary permissions.", e.EntityType) |
| 127 | } |
| 128 | |
| 129 | return b.String() |
| 130 | } |
| 131 | |
| 132 | // Unwrap returns the underlying error |
| 133 | func (e *OperationError) Unwrap() error { |