Przygotuj się na nieznane
Zawsze opakowuj operacje na zasobach w bloki try-except:
import cgc.sdk.resource as resource
import cgc.sdk.exceptions as exceptions
try:
response = resource.resource_create(
name="my-app",
image_name="nginx:latest",
cpu=2,
memory=4
)
if response['code'] == 200:
print("Success!")
else:
print(f"Failed: {response['message']}")
except exceptions.SDKException as e:
print(f"SDK Error (code {e.code}): {e}")
except Exception as e:
print(f"Unexpected error: {e}")