FabricFabricHarness
Reference

Errors

Handle stable Fabric error codes without exposing secrets or host paths.

Fabric errors have a stable code, retryability, and optional structured details. Match codes, not message text:

import { FabricError } from '@fabric-harness/sdk';

try {
  await session.prompt('Run the report');
} catch (error) {
  if (error instanceof FabricError && error.code === 'MODEL_RATE_LIMITED') {
    await retryLater();
  }
  throw error;
}

Use serializeFabricError(error, 'public') at an HTTP or queue boundary. Public serialization uses the safe message and public details, removes filesystem paths, and redacts authorization values, tokens, API keys, passwords, credentials, and known provider-key formats. Developer serialization retains diagnostic context but still redacts secrets.

import { serializeFabricError } from '@fabric-harness/sdk';

return Response.json(
  { error: serializeFabricError(error, 'public') },
  { status: 500 },
);

The Node package exports two specialized subclasses:

ClassStable codes
FabricBuildErrorBUILD_FAILED, BUILD_INVALID_TARGET, BUILD_VERIFICATION_FAILED
FabricPersistenceErrorPERSISTENCE_CONFLICT, PERSISTENCE_UNAVAILABLE, PERSISTENCE_INVALID_CONFIG, SESSION_NOT_FOUND

PERSISTENCE_CONFLICT is retryable when an ownership lease or optimistic version loses a race. Configuration and verification errors are not retryable until the caller changes input or the artifact. @fabric-harness/client preserves server code, details, and retryable on FabricClientError, so browser and service clients can use the same branching logic.