Error Handling
Automation should handle GraphQL failures by category. Do not branch on human-readable error messages.
GraphQL errors include extensions.code and may include extensions.status.
Categories
unauthenticated— no valid session is attached. Log in again and retry.forbidden— the session is valid, but the user role cannot access the resolver or object.validation— the input shape or value is not acceptable.not_found— the requested route, source, output, artifact, node, user, or settings target does not exist.conflict— the requested state conflicts with current durable state, ownership, or command preconditions.persistence_failure— a durable write failed.runtime_unavailable— runtime state needed by the resolver is not readable right now.operation_rejected— an exceptional operation, such as a Fleet command, was rejected or could not be safely applied.unknown— the client could not classify the server code.
Representative codes:
UNAUTHORIZEDmaps tounauthenticated.FORBIDDENmaps toforbidden.INVALID_USERNAME,INVALID_SPEC,EMPTY_PASSWORD, and status400map tovalidation.ROUTE_NOT_FOUND,FILE_NOT_FOUND,USER_NOT_FOUND, and status404map tonot_found.DUPLICATE_ROUTE_NAME,FIRST_USER_MUST_BE_ADMIN,LAST_ADMIN_REQUIRED, and status409map toconflict.FILE_PERSISTENCE_FAILED,FILE_TAG_PERSISTENCE_FAILED, andUSER_PERSISTENCE_FAILEDmap topersistence_failure.PLAYLIST_RUNTIME_STATE_UNAVAILABLEandOUTPUT_RUNTIME_STATE_UNAVAILABLEmap toruntime_unavailable.STALE_ASSIGNMENTand rejected Fleet command codes map tooperation_rejected.
TypeScript Classification
import { GraphQLError, classifyGraphQLError } from '@fluxomni/api-client';
try {
await client.executeRaw('query Routes { routes { allRoutes { id } } }');
} catch (error) {
if (error instanceof GraphQLError) {
for (const serverError of error.errors) {
switch (classifyGraphQLError(serverError)) {
case 'unauthenticated':
throw new Error('Session expired; log in again.');
case 'forbidden':
throw new Error('The current role cannot run this operation.');
case 'not_found':
console.warn('Target was already absent:', serverError.code);
break;
default:
throw error;
}
}
}
}
Mutation result payloads are not exceptions. Treat UPDATED, UNCHANGED, and NOT_FOUND as normal convergence outcomes when the schema returns a result payload.