(label: string, cause: unknown)
| 199 | Predicate.isTagged(error, "UniqueViolationError"); |
| 200 | |
| 201 | export const fumaFailureFromCause = (label: string, cause: unknown): StorageFailure => { |
| 202 | if (isStorageFailure(cause)) return cause; |
| 203 | if (isUniqueViolation(cause)) return new UniqueViolationError({ model: label }); |
| 204 | const connectionCode = connectionFaultCode(cause); |
| 205 | if (connectionCode !== undefined) { |
| 206 | return new StorageConnectionError({ |
| 207 | message: stableMessage(label, connectionCode), |
| 208 | label, |
| 209 | code: connectionCode, |
| 210 | retryable: RETRYABLE_CONNECTION_CODES.has(connectionCode), |
| 211 | cause, |
| 212 | }); |
| 213 | } |
| 214 | return new StorageError({ |
| 215 | message: stableMessage(label, causeCode(cause)), |
| 216 | operation: label, |
| 217 | code: causeCode(cause), |
| 218 | cause, |
| 219 | }); |
| 220 | }; |
| 221 | |
| 222 | export const fumaEffect = <A>( |
| 223 | label: string, |
no test coverage detected