Merge branch 'main' into add-kapwa-registry-to-directory

This commit is contained in:
Nicu Listana
2026-02-20 22:36:08 -08:00
committed by GitHub
4 changed files with 31 additions and 1 deletions

View File

@@ -472,7 +472,7 @@ Let's make the email column sortable.
### Update `<DataTable>`
```tsx showLineNumbers title="app/payments/data-table.tsx" showLineNumbers {3,6,10,18,25-28}
```tsx showLineNumbers title="app/payments/data-table.tsx" showLineNumbers {3,6,10,18,25-29}
"use client"
import * as React from "react"

View File

@@ -5,6 +5,7 @@ export const RegistryErrorCode = {
// Network errors
NETWORK_ERROR: "NETWORK_ERROR",
NOT_FOUND: "NOT_FOUND",
GONE: "GONE",
UNAUTHORIZED: "UNAUTHORIZED",
FORBIDDEN: "FORBIDDEN",
FETCH_ERROR: "FETCH_ERROR",
@@ -90,6 +91,22 @@ export class RegistryNotFoundError extends RegistryError {
}
}
export class RegistryGoneError extends RegistryError {
constructor(public readonly url: string, cause?: unknown) {
const message = `The item at ${url} is no longer available. It may have been removed or expired.`
super(message, {
code: RegistryErrorCode.GONE,
statusCode: 410,
cause,
context: { url },
suggestion:
"This resource was previously available but has been permanently removed. Check if a newer version exists or contact the registry maintainer.",
})
this.name = "RegistryGoneError"
}
}
export class RegistryUnauthorizedError extends RegistryError {
constructor(public readonly url: string, cause?: unknown) {
const message = `You are not authorized to access the item at ${url}. If this is a remote registry, you may need to authenticate.`

View File

@@ -2,6 +2,7 @@ import { REGISTRY_URL } from "@/src/registry/constants"
import {
RegistryFetchError,
RegistryForbiddenError,
RegistryGoneError,
RegistryNotFoundError,
RegistryUnauthorizedError,
} from "@/src/registry/errors"
@@ -30,6 +31,9 @@ const server = setupServer(
http.get(`${REGISTRY_URL}/forbidden.json`, () => {
return new HttpResponse(null, { status: 403 })
}),
http.get(`${REGISTRY_URL}/gone.json`, () => {
return new HttpResponse(null, { status: 410 })
}),
http.get("https://external.com/component.json", () => {
return HttpResponse.json({
name: "external",
@@ -123,6 +127,10 @@ describe("fetchRegistry", () => {
)
})
it("should handle 410 errors", async () => {
await expect(fetchRegistry(["gone.json"])).rejects.toThrow(RegistryGoneError)
})
it("should handle network errors", async () => {
await expect(fetchRegistry(["error.json"])).rejects.toThrow()
})

View File

@@ -6,6 +6,7 @@ import { getRegistryHeadersFromContext } from "@/src/registry/context"
import {
RegistryFetchError,
RegistryForbiddenError,
RegistryGoneError,
RegistryLocalFileError,
RegistryNotFoundError,
RegistryParseError,
@@ -93,6 +94,10 @@ export async function fetchRegistry(
throw new RegistryNotFoundError(url, messageFromServer)
}
if (response.status === 410) {
throw new RegistryGoneError(url, messageFromServer)
}
if (response.status === 403) {
throw new RegistryForbiddenError(url, messageFromServer)
}