Files
OpenShell/sdk/go/openshell/v1/errors.go
Mrunal Patel 39cf4823f7 feat(api): add structured gateway errors and SDK decoding (#3313)
* feat(api): expose structured gateway errors across SDKs

Refs #3051. Add standard validation, conflict, and retry details; preserve raw transport status in Rust, Go, TypeScript, and Python; document status and recovery guidance.

This is the structured-error foundation only. Mutation result shapes, allow_missing, durable request deduplication, and exec retry semantics remain follow-up work.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

* fix(python): preserve wrapped RPC cleanup handling

Inspect the original gRPC call when handling missing sandboxes during deletion waits and managed cleanup. Add intercepted cleanup regressions and clarify the error-wrapper migration contract.

Addresses the cleanup review on #3313; part of #3051.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

---------

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2026-09-15 17:51:11 +00:00

67 lines
2.8 KiB
Go

// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package v1
import (
"github.com/NVIDIA/OpenShell/sdk/go/openshell/v1/types"
)
// ErrorCode classifies SDK errors by their gRPC origin.
type ErrorCode = types.ErrorCode
// ErrorCode values for classifying gRPC errors.
const (
ErrorNotFound = types.ErrorNotFound
ErrorAlreadyExists = types.ErrorAlreadyExists
ErrorUnavailable = types.ErrorUnavailable
ErrorPermissionDenied = types.ErrorPermissionDenied
ErrorInvalidArgument = types.ErrorInvalidArgument
ErrorDeadlineExceeded = types.ErrorDeadlineExceeded
ErrorCancelled = types.ErrorCancelled
ErrorInternal = types.ErrorInternal
ErrorUnimplemented = types.ErrorUnimplemented
ErrorConflict = types.ErrorConflict
ErrorUnauthenticated = types.ErrorUnauthenticated
)
// StatusError is the typed error returned by all SDK operations.
type StatusError = types.StatusError
// FieldViolation identifies an invalid request field.
type FieldViolation = types.FieldViolation
// ErrorInfo describes a server failure using a stable reason within a domain.
type ErrorInfo = types.ErrorInfo
// IsNotFound returns true if the error indicates a resource was not found.
func IsNotFound(err error) bool { return types.IsNotFound(err) }
// IsAlreadyExists returns true if the error indicates a resource already exists.
func IsAlreadyExists(err error) bool { return types.IsAlreadyExists(err) }
// IsUnavailable returns true if the error indicates the service is unavailable.
func IsUnavailable(err error) bool { return types.IsUnavailable(err) }
// IsPermissionDenied returns true if the error indicates insufficient permissions.
func IsPermissionDenied(err error) bool { return types.IsPermissionDenied(err) }
// IsInvalidArgument returns true if the error indicates an invalid argument.
func IsInvalidArgument(err error) bool { return types.IsInvalidArgument(err) }
// IsDeadlineExceeded returns true if the error indicates a deadline was exceeded.
func IsDeadlineExceeded(err error) bool { return types.IsDeadlineExceeded(err) }
// IsCancelled returns true if the error indicates the operation was cancelled.
func IsCancelled(err error) bool { return types.IsCancelled(err) }
// IsUnimplemented returns true if the error indicates the operation is not implemented.
func IsUnimplemented(err error) bool { return types.IsUnimplemented(err) }
// IsConflict returns true if the error indicates a conflict, such as
// optimistic concurrency or an invalid state transition.
func IsConflict(err error) bool { return types.IsConflict(err) }
// IsUnauthenticated returns true if the error indicates invalid or missing credentials.
func IsUnauthenticated(err error) bool { return types.IsUnauthenticated(err) }