Summary
FgaError currently computes its message with:
msg || typeof err === "string" ? (err as string) : `FGA Error ...`
Because of JavaScript operator precedence, this is parsed as:
(msg || typeof err === "string") ? (err as string) : ...
So when a truthy msg is provided, msg is ignored and err is used instead.
Impact
Callers that pass a custom message cannot rely on it being honored, which breaks error wrapping semantics.
Expected
If msg is provided, it should be used as the error message. Otherwise, derive message from err.
Proposed Fix
Use explicit grouping/nullish coalescing, for example:
super(msg ?? (typeof err === "string" ? err : ...));
Summary
FgaErrorcurrently computes its message with:Because of JavaScript operator precedence, this is parsed as:
So when a truthy
msgis provided,msgis ignored anderris used instead.Impact
Callers that pass a custom message cannot rely on it being honored, which breaks error wrapping semantics.
Expected
If
msgis provided, it should be used as the error message. Otherwise, derive message fromerr.Proposed Fix
Use explicit grouping/nullish coalescing, for example: