API Reference@flopay/shared
Errors
FloPayError class and error factory functions exported by @flopay/shared.
FloPayErrorType
Discriminated union of all error types returned by the FloPay SDK.
FloPayError
Custom error class for all FloPay SDK errors. Extends the native Error and adds structured fields.
Constructor
| Parameter | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Human-readable error message. |
type | FloPayErrorType | Yes | Error category. |
options.code | string | No | Machine-readable error code. |
options.declineCode | string | No | Card decline code (e.g. "insufficient_funds"). |
options.param | string | No | The parameter that caused the error. |
Properties
| Property | Type | Description |
|---|---|---|
message | string | Human-readable error message (inherited from Error). |
name | string | Always "FloPayError". |
type | FloPayErrorType | Error category. |
code | string | undefined | Machine-readable error code. |
declineCode | string | undefined | Card decline code. |
param | string | undefined | The parameter that caused the error. |
Example
Factory Functions
Convenience functions that create FloPayError instances with the correct type.
validationError
Creates a validation error (e.g. missing required field).
| Parameter | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Error message. |
param | string | No | The invalid parameter name. |
apiError
Creates an API error (e.g. upstream provider returned an error).
| Parameter | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Error message. |
code | string | No | Machine-readable error code. |
authenticationError
Creates an authentication error (e.g. invalid publishable key).
| Parameter | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Error message. |
rateLimitError
Creates a rate limit error.
| Parameter | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Error message. |
networkError
Creates a network error (e.g. fetch failed).
| Parameter | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Error message. |