studio-error-handling

bởi supabase

Mẫu hiển thị lỗi và khắc phục sự cố cho Supabase Studio. Sử dụng khi

npx skills add https://github.com/supabase/supabase --skill studio-error-handling

Studio Error Handling Pattern

Full docs and code examples: apps/studio/components/interfaces/ErrorHandling/README.md

How it works

Classification happens in the data layer: handleError in data/fetchers.ts tests the error message against ERROR_PATTERNS and throws the matching error subclass (e.g. ConnectionTimeoutError extends ResponseError). The component (ErrorMatcher) reads errorType from the instance and does an O(1) lookup — it never does regex matching.

handleError() → throws ConnectionTimeoutError → React Query catches → ErrorMatcher reads errorType → renders troubleshooting

Key files

FilePurpose
data/error-patterns.tsArray of { pattern, ErrorClass } — the regex lives here
types/api-errors.tsError classes, KnownErrorType union, ClassifiedError type
ErrorMatcher.tsxComponent — reads errorType, looks up mapping, renders
error-mappings.tsxRecord<KnownErrorType, { id, Troubleshooting: ComponentType }>
errorMappings/ConnectionTimeout.tsxReference troubleshooting component
TroubleshootingSections.tsxReusable accordion section components
TroubleshootingAccordion.tsxAccordion wrapper with telemetry

Usage

Pass the full error object from React Query — not error.message:

{
  isError && (
    <ErrorMatcher title="Failed to load tables" error={error} supportFormParams={{ projectRef }} />
  )
}

What NOT to do

  • Do not pass error.message to ErrorMatcher — pass the full error object so the class is preserved.
  • Do not put regex patterns in error-mappings.tsx — they belong in data/error-patterns.ts.
  • Do not use Object.assign to stamp errorType — throw a proper subclass instead.
  • Do not pass a raw URL string for support — use supportFormParams={{ projectRef }}.
  • Do not put the page title inside the error mapping — it belongs on the <ErrorMatcher> caller.
  • Do not add callback props (onDebugWithAI, onRestartProject) to troubleshooting components — use hooks inside them instead.

Thêm skills từ supabase

studio-e2e-tests
supabase
Viết và chạy các bài kiểm tra E2E Playwright cho Supabase Studio. Sử dụng khi được yêu cầu.
pm-the-docs
supabase
Hỗ trợ ra quyết định Docs-PM cho quy trình biên soạn "Write the docs" — đưa ra các quyết định về đối tượng, giai đoạn và phạm vi xuyên suốt trong các giai đoạn Frame và Shape,…
studio-best-practices
supabase
Các phương pháp hay nhất về React và TypeScript cho Supabase Studio. Sử dụng khi viết hoặc xem xét các thành phần Studio — bao gồm đặt tên boolean, cấu trúc thành phần,…
docs-content
supabase
Viết, chỉnh sửa, sắp xếp và xem lại nội dung Supabase ở bất kỳ đâu trong apps/docs — hướng dẫn, bài giải thích, bài hướng dẫn, mục xử lý sự cố, tài liệu tham khảo, và…
studio-mock-api-tests
supabase
Các bài kiểm tra thành phần cho Supabase Studio mô phỏng các yêu cầu API ở lớp mạng bằng MSW. Sử dụng khi viết hoặc xem xét một bài kiểm tra thành phần thao tác với một React…
studio-ui-patterns
supabase
Các mẫu UI của hệ thống thiết kế cho Supabase Studio. Sử dụng khi xây dựng hoặc cập nhật trang, biểu mẫu, bảng, biểu đồ, trạng thái trống, điều hướng, thẻ, cảnh báo hoặc bên…
react-hook-form
supabase
Sử dụng React Hook Form đúng cách ở bất kỳ đâu trong monorepo — luồng dữ liệu, đăng ký, reset, trạng thái dirty, input số và quy tắc input có kiểm soát. Tải cái này…
studio-queries
supabase
React Query quy ước cho việc lấy dữ liệu trong Supabase Studio. Sử dụng khi viết hoặc xem xét query hooks, mutation hooks, hoặc query keys trong apps/studio/data/ —…