MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / domain_status

Function domain_status

libatomic/src/daemon/state.rs:389–453  ·  view source on GitHub ↗

A domain refusal as a gRPC status carrying the contract's stable machine-readable ErrorInfo detail.

(code: ErrorCode, message: impl Into<String>)

Source from the content-addressed store, hash-verified

387/// A domain refusal as a gRPC status carrying the contract's stable
388/// machine-readable ErrorInfo detail.
389pub fn domain_status(code: ErrorCode, message: impl Into<String>) -> Status {
390 let message: String = message.into();
391 fn code_name(code: ErrorCode) -> &'static str {
392 match code {
393 ErrorCode::Unspecified => "ERROR_CODE_UNSPECIFIED",
394 ErrorCode::CapabilityUnavailable => "CAPABILITY_UNAVAILABLE",
395 ErrorCode::ProtocolVersionMismatch => "PROTOCOL_VERSION_MISMATCH",
396 ErrorCode::WorkspaceRequired => "WORKSPACE_REQUIRED",
397 ErrorCode::Unauthorized => "UNAUTHORIZED",
398 ErrorCode::Forbidden => "FORBIDDEN",
399 ErrorCode::SandboxToken => "SANDBOX_TOKEN",
400 ErrorCode::IdempotencyMismatch => "IDEMPOTENCY_MISMATCH",
401 ErrorCode::PreconditionFailed => "PRECONDITION_FAILED",
402 ErrorCode::GenerationConflict => "GENERATION_CONFLICT",
403 ErrorCode::InvalidArgument => "INVALID_ARGUMENT",
404 ErrorCode::NotFound => "NOT_FOUND",
405 ErrorCode::Repository => "REPOSITORY",
406 ErrorCode::RepositoryNotFound => "REPOSITORY_NOT_FOUND",
407 ErrorCode::ResourceExhausted => "RESOURCE_EXHAUSTED",
408 ErrorCode::RateLimited => "RATE_LIMITED",
409 ErrorCode::View => "VIEW",
410 ErrorCode::ViewStale => "VIEW_STALE",
411 ErrorCode::ChangeRejected => "CHANGE_REJECTED",
412 ErrorCode::ProvenanceStore => "PROVENANCE_STORE",
413 ErrorCode::ProvenanceCheckpoint => "PROVENANCE_CHECKPOINT",
414 ErrorCode::ProvenanceLifecycle => "PROVENANCE_LIFECYCLE",
415 ErrorCode::Provenance => "PROVENANCE",
416 ErrorCode::Changes => "CHANGES",
417 ErrorCode::FileStates => "FILE_STATES",
418 ErrorCode::Materialize => "MATERIALIZE",
419 ErrorCode::Remote => "REMOTE",
420 ErrorCode::Internal => "INTERNAL",
421 }
422 }
423 let info = ErrorInfo {
424 code: code as i32,
425 message: message.clone(),
426 context: HashMap::new(),
427 request_id: None,
428 };
429 let mut payload = Vec::new();
430 let _ = info.encode(&mut payload);
431 let _ = payload;
432 let grpc_code = match code {
433 ErrorCode::NotFound | ErrorCode::RepositoryNotFound => Code::NotFound,
434 ErrorCode::InvalidArgument => Code::InvalidArgument,
435 ErrorCode::PreconditionFailed
436 | ErrorCode::GenerationConflict
437 | ErrorCode::IdempotencyMismatch
438 | ErrorCode::ViewStale
439 | ErrorCode::ChangeRejected => Code::FailedPrecondition,
440 ErrorCode::ResourceExhausted | ErrorCode::RateLimited => Code::ResourceExhausted,
441 ErrorCode::Unauthorized => Code::Unauthenticated,
442 ErrorCode::Forbidden | ErrorCode::SandboxToken | ErrorCode::View => Code::PermissionDenied,
443 ErrorCode::ProtocolVersionMismatch => Code::Internal,
444 ErrorCode::Internal | ErrorCode::Repository => Code::Internal,
445 _ => Code::InvalidArgument,
446 };

Callers 15

sync_credentialsMethod · 0.85
get_change_implFunction · 0.85
get_session_implFunction · 0.85
create_viewMethod · 0.85
switch_viewMethod · 0.85
delete_viewMethod · 0.85
set_view_scopeMethod · 0.85
split_viewMethod · 0.85
validate_view_nameFunction · 0.85
resolve_repositoryMethod · 0.85
register_repositoryMethod · 0.85

Calls 2

cloneMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected