Resolve Client.Go-001 code-review finding
MxAccessError.Unwrap returned e.Command directly; on the HRESULT-only path Command is a nil *CommandError, so Unwrap returned a non-nil error wrapping a typed nil and errors.As bound a nil *CommandError. Unwrap now returns an untyped nil when Command is nil. Added errors_test.go regression coverage for the HRESULT-only and populated-Command paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -85,8 +85,12 @@ func (e *MxAccessError) Error() string {
|
||||
}
|
||||
|
||||
// Unwrap returns the wrapped CommandError, when one is present.
|
||||
//
|
||||
// When Command is nil (the HRESULT / MxStatusProxy path) it returns an
|
||||
// untyped nil rather than a typed-nil *CommandError, so errors.As does not
|
||||
// bind a nil pointer that a caller would then panic on.
|
||||
func (e *MxAccessError) Unwrap() error {
|
||||
if e == nil {
|
||||
if e == nil || e.Command == nil {
|
||||
return nil
|
||||
}
|
||||
return e.Command
|
||||
|
||||
Reference in New Issue
Block a user