15 lines
594 B
TypeScript
15 lines
594 B
TypeScript
import { apiError, API_ERROR_CODES } from '@/lib/server/api-response';
|
|
import {
|
|
isServerManagedProviderRequiredError,
|
|
SERVER_MANAGED_PROVIDER_REQUIRED_MESSAGE,
|
|
} from '@/lib/server/provider-access-policy';
|
|
|
|
/**
|
|
* Map the central provider deployment denial to one stable public API shape.
|
|
* Returns null for unrelated errors so each route keeps its existing handling.
|
|
*/
|
|
export function providerAccessApiError(error: unknown) {
|
|
if (!isServerManagedProviderRequiredError(error)) return null;
|
|
return apiError(API_ERROR_CODES.FORBIDDEN, 403, SERVER_MANAGED_PROVIDER_REQUIRED_MESSAGE);
|
|
}
|