Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:FlowiseAI Flowise ErrorContext

From Leeroopedia
Revision as of 11:15, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/FlowiseAI_Flowise_ErrorContext.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Error Handling, State Management
Last Updated 2026-02-12 07:00 GMT

Overview

ErrorContext is a React context provider that centralizes HTTP error handling across the Flowise UI, managing authentication failures, rate limiting, authorization errors, and general error state.

Description

ErrorContext creates a shared error handling context using createContext and exposes an ErrorProvider component along with a useError hook. The provider's handleError function inspects HTTP response status codes (401, 403, 429) and routes the user to the appropriate page (login, unauthorized, rate-limited) or dispatches a logout action. It also distinguishes between authentication rate limits and general rate limits, parsing the Retry-After header to determine wait times.

Usage

Wrap the application with <ErrorProvider> so that any component can call handleError(err) from the useError() hook to trigger centralized error routing. This is typically called from API interceptors or catch blocks throughout the application.

Code Reference

Source Location

Signature

export const ErrorProvider = ({ children }) => { ... }
export const useError = () => useContext(ErrorContext)

Import

import { ErrorProvider, useError } from '@/store/context/ErrorContext'

I/O Contract

Inputs

Name Type Required Description
children PropTypes.any Yes Child React elements to be wrapped by the provider

Outputs

Name Type Description
error object or null The most recent unhandled error object
setError function Setter to manually update the error state
handleError function Async handler that routes errors based on HTTP status code (401, 403, 429)
authRateLimitError string or null Message shown when authentication rate limit (429 with type 'authentication_rate_limit') is hit
setAuthRateLimitError function Setter to manually update the auth rate limit error message

Usage Examples

Basic Usage

import { ErrorProvider, useError } from '@/store/context/ErrorContext'

// Wrap app with ErrorProvider
function App() {
    return (
        <ErrorProvider>
            <Dashboard />
        </ErrorProvider>
    )
}

// Use in a component to handle API errors
function Dashboard() {
    const { handleError, error } = useError()

    const fetchData = async () => {
        try {
            const response = await api.getData()
            // handle response
        } catch (err) {
            handleError(err)
        }
    }

    return (
        <div>
            {error && <div>Something went wrong</div>}
            <button onClick={fetchData}>Load Data</button>
        </div>
    )
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment