MCPcopy Create free account
hub / github.com/agenticsorg/edge-agents / aws_operation

Function aws_operation

scripts/agents/devops/src/aws/base.py:434–461  ·  view source on GitHub ↗

Decorator for AWS operations that handles common errors. Args: operation_name: Name of the operation, defaults to the function name. Returns: Decorated function.

(operation_name=None)

Source from the content-addressed store, hash-verified

432
433# Common decorator for AWS operations with error handling
434def aws_operation(operation_name=None):
435 """
436 Decorator for AWS operations that handles common errors.
437
438 Args:
439 operation_name: Name of the operation, defaults to the function name.
440
441 Returns:
442 Decorated function.
443 """
444 def decorator(func):
445 def wrapper(self, *args, **kwargs):
446 op_name = operation_name or func.__name__
447 try:
448 return func(self, *args, **kwargs)
449 except (AWSServiceError, ResourceNotFoundError,
450 PermissionDeniedError, ValidationError,
451 RateLimitError, ResourceLimitError) as e:
452 # Re-raise known exceptions
453 raise
454 except Exception as e:
455 # Handle and convert unknown exceptions
456 if isinstance(self, AWSBaseService):
457 self.handle_error(e, op_name)
458 else:
459 raise AWSServiceError(f"{op_name} failed: {e}")
460 return wrapper
461 return decorator

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected