2020from cdpcli .client import ClientCreator , Context
2121from cdpcli .credentials import Credentials
2222from cdpcli .endpoint import EndpointCreator , EndpointResolver
23- from cdpcli .exceptions import ClientError
23+ from cdpcli .exceptions import ClientError , ParamValidationError
2424from cdpcli .loader import Loader
2525from cdpcli .parser import ResponseParserFactory
2626from cdpcli .retryhandler import create_retry_handler
@@ -65,13 +65,23 @@ def __init__(self, base_error, *args):
6565 except KeyError :
6666 self .error_code = ''
6767 self .violations = _violations
68- self .message = _violations
68+ self .message = "Client request error"
6969 self .status_code = _payload .group (1 )
7070 self .rc = 1
7171 self .service = _payload .group (3 )
7272 self .operation = _payload .group (4 )
7373 self .request_id = _payload .group (5 )
7474
75+ if isinstance (self .base_error , ParamValidationError ):
76+ _PARAM_ERROR_PATTERN = re .compile (
77+ r"Parameter validation failed:\n([\s\S]*)"
78+ )
79+ _payload = re .search (_PARAM_ERROR_PATTERN , str (self .base_error ))
80+ _violations = _payload .group (1 ).split ('\n ' )
81+ self .violations = _violations
82+ self .message = "Parameter validation error"
83+ self .error_code = 'PARAMETER_VALIDATION_ERROR'
84+
7585 super ().__init__ (base_error , * args )
7686
7787 def update (self , * args , ** kwargs ):
@@ -186,6 +196,7 @@ def _warning_format(message, category, filename, lineno, line=None):
186196 'STOP_IN_PROGRESS' ,
187197 'STOPPED' ,
188198 'ENV_STOPPED' ,
199+ 'Stopped' , # DW
189200 'NOT_ENABLED' # DF
190201 ]
191202
@@ -207,7 +218,7 @@ def _warning_format(message, category, filename, lineno, line=None):
207218 'AVAILABLE' , 'UPDATE_FAILED' , 'CREATE_FAILED' , 'ENABLE_SECURITY_FAILED' , 'DELETE_FAILED' ,
208219 'DELETE_COMPLETED' , 'DELETED_ON_PROVIDER_SIDE' , 'STOPPED' , 'START_FAILED' , 'STOP_FAILED' ,
209220 'installation:failed' , 'deprovision:failed' , 'installation:finished' , # ML
210- 'Error' , 'Running' , # DW
221+ 'Error' , 'Running' , 'Stopped' , 'Deleting' , # DW
211222 'GOOD_HEALTH' , 'CONCERNING_HEALTH' , 'BAD_HEALTH' , # DF
212223 ]
213224
0 commit comments