feat(clients/go): typed ErrUnauthenticated/ErrPermissionDenied on GatewayError (mxaccessgw#198)

This commit is contained in:
Joseph Doherty
2026-11-09 12:02:31 -05:00
parent e5e7f1854f
commit f13a747084
3 changed files with 66 additions and 1 deletions
+5 -1
View File
@@ -92,7 +92,11 @@ returned subscription owns cancellation and exposes `Close` for deterministic
goroutine cleanup. Raw protobuf messages remain available through the
`mxgateway` package aliases and the `Raw` helper methods. Typed errors support
`errors.As` for `GatewayError`, `CommandError`, and `MxAccessError`; command
errors preserve the raw reply.
errors preserve the raw reply. Authentication failures are distinguishable with
`errors.Is(err, mxgateway.ErrUnauthenticated)` (missing/rejected API key) and
`errors.Is(err, mxgateway.ErrPermissionDenied)` (valid key, not authorised);
both match a `*GatewayError` by its gRPC status code and leave the message
(and its credential redaction) unchanged.
`EnsureMxAccessSuccess` follows COM semantics: only a **negative** HRESULT is a
failure, so positive success codes such as `S_FALSE` (1) pass. `StatusSucceeded`