@@ -48,7 +48,7 @@ import {
4848 DescribeChangeSetResult ,
4949} from '../stacks/StackRequestType' ;
5050import { LoggerFactory } from '../telemetry/LoggerFactory' ;
51- import { extractErrorMessage } from '../utils/Errors' ;
51+ import { handleLspError } from '../utils/Errors' ;
5252import { parseWithPrettyError } from '../utils/ZodErrorWrapper' ;
5353
5454const log = LoggerFactory . getLogger ( 'StackHandler' ) ;
@@ -74,7 +74,7 @@ export function getParametersHandler(
7474 parameters : [ ] ,
7575 } ;
7676 } catch ( error ) {
77- handleStackActionError ( error , 'Failed to get parameters' ) ;
77+ handleLspError ( error , 'Failed to get parameters' ) ;
7878 }
7979 } ;
8080}
@@ -87,7 +87,7 @@ export function createValidationHandler(
8787 const params = parseWithPrettyError ( parseCreateValidationParams , rawParams ) ;
8888 return await components . validationWorkflowService . start ( params ) ;
8989 } catch ( error ) {
90- handleStackActionError ( error , 'Failed to start validation workflow' ) ;
90+ handleLspError ( error , 'Failed to start validation workflow' ) ;
9191 }
9292 } ;
9393}
@@ -100,7 +100,7 @@ export function createDeploymentHandler(
100100 const params = parseWithPrettyError ( parseCreateDeploymentParams , rawParams ) ;
101101 return await components . deploymentWorkflowService . start ( params ) ;
102102 } catch ( error ) {
103- handleStackActionError ( error , 'Failed to start deployment workflow' ) ;
103+ handleLspError ( error , 'Failed to start deployment workflow' ) ;
104104 }
105105 } ;
106106}
@@ -113,7 +113,7 @@ export function getValidationStatusHandler(
113113 const params = parseWithPrettyError ( parseIdentifiable , rawParams ) ;
114114 return components . validationWorkflowService . getStatus ( params ) ;
115115 } catch ( error ) {
116- handleStackActionError ( error , 'Failed to get validation status' ) ;
116+ handleLspError ( error , 'Failed to get validation status' ) ;
117117 }
118118 } ;
119119}
@@ -126,7 +126,7 @@ export function getDeploymentStatusHandler(
126126 const params = parseWithPrettyError ( parseIdentifiable , rawParams ) ;
127127 return components . deploymentWorkflowService . getStatus ( params ) ;
128128 } catch ( error ) {
129- handleStackActionError ( error , 'Failed to get deployment status' ) ;
129+ handleLspError ( error , 'Failed to get deployment status' ) ;
130130 }
131131 } ;
132132}
@@ -139,7 +139,7 @@ export function describeValidationStatusHandler(
139139 const params = parseWithPrettyError ( parseIdentifiable , rawParams ) ;
140140 return components . validationWorkflowService . describeStatus ( params ) ;
141141 } catch ( error ) {
142- handleStackActionError ( error , 'Failed to describe validation status' ) ;
142+ handleLspError ( error , 'Failed to describe validation status' ) ;
143143 }
144144 } ;
145145}
@@ -152,7 +152,7 @@ export function describeDeploymentStatusHandler(
152152 const params = parseWithPrettyError ( parseIdentifiable , rawParams ) ;
153153 return components . deploymentWorkflowService . describeStatus ( params ) ;
154154 } catch ( error ) {
155- handleStackActionError ( error , 'Failed to describe deployment status' ) ;
155+ handleLspError ( error , 'Failed to describe deployment status' ) ;
156156 }
157157 } ;
158158}
@@ -165,7 +165,7 @@ export function deleteChangeSetHandler(
165165 const params = parseWithPrettyError ( parseDeleteChangeSetParams , rawParams ) ;
166166 return await components . changeSetDeletionWorkflowService . start ( params ) ;
167167 } catch ( error ) {
168- handleStackActionError ( error , 'Failed to start change set deletion workflow' ) ;
168+ handleLspError ( error , 'Failed to start change set deletion workflow' ) ;
169169 }
170170 } ;
171171}
@@ -178,7 +178,7 @@ export function getChangeSetDeletionStatusHandler(
178178 const params = parseWithPrettyError ( parseIdentifiable , rawParams ) ;
179179 return components . changeSetDeletionWorkflowService . getStatus ( params ) ;
180180 } catch ( error ) {
181- handleStackActionError ( error , 'Failed to get change set deletion status' ) ;
181+ handleLspError ( error , 'Failed to get change set deletion status' ) ;
182182 }
183183 } ;
184184}
@@ -191,7 +191,7 @@ export function describeChangeSetDeletionStatusHandler(
191191 const params = parseWithPrettyError ( parseIdentifiable , rawParams ) ;
192192 return components . changeSetDeletionWorkflowService . describeStatus ( params ) ;
193193 } catch ( error ) {
194- handleStackActionError ( error , 'Failed to describe change set deletion status' ) ;
194+ handleLspError ( error , 'Failed to describe change set deletion status' ) ;
195195 }
196196 } ;
197197}
@@ -211,7 +211,7 @@ export function getCapabilitiesHandler(
211211
212212 return { capabilities } ;
213213 } catch ( error ) {
214- handleStackActionError ( error , 'Failed to analyze template capabilities' ) ;
214+ handleLspError ( error , 'Failed to analyze template capabilities' ) ;
215215 }
216216 } ;
217217}
@@ -252,7 +252,7 @@ export function getTemplateResourcesHandler(
252252
253253 return { resources } ;
254254 } catch ( error ) {
255- handleStackActionError ( error , 'Failed to get template resources' ) ;
255+ handleLspError ( error , 'Failed to get template resources' ) ;
256256 }
257257 } ;
258258}
@@ -377,7 +377,7 @@ export function getStackEventsHandler(
377377 }
378378 return await components . stackEventManager . fetchEvents ( params . stackName , params . nextToken ) ;
379379 } catch ( error ) {
380- handleStackActionError ( error , 'Failed to get stack events' ) ;
380+ handleLspError ( error , 'Failed to get stack events' ) ;
381381 }
382382 } ;
383383}
@@ -390,7 +390,7 @@ export function clearStackEventsHandler(
390390 parseWithPrettyError ( parseClearStackEventsParams , rawParams ) ;
391391 components . stackEventManager . clear ( ) ;
392392 } catch ( error ) {
393- handleStackActionError ( error , 'Failed to clear stack events' ) ;
393+ handleLspError ( error , 'Failed to clear stack events' ) ;
394394 }
395395 } ;
396396}
@@ -405,17 +405,7 @@ export function getStackOutputsHandler(
405405 const outputs = response . Stacks ?. [ 0 ] ?. Outputs ?? [ ] ;
406406 return { outputs } ;
407407 } catch ( error ) {
408- handleStackActionError ( error , 'Failed to get stack outputs' ) ;
408+ handleLspError ( error , 'Failed to get stack outputs' ) ;
409409 }
410410 } ;
411411}
412-
413- function handleStackActionError ( error : unknown , contextMessage : string ) : never {
414- if ( error instanceof ResponseError ) {
415- throw error ;
416- }
417- if ( error instanceof TypeError ) {
418- throw new ResponseError ( ErrorCodes . InvalidParams , error . message ) ;
419- }
420- throw new ResponseError ( ErrorCodes . InternalError , `${ contextMessage } : ${ extractErrorMessage ( error ) } ` ) ;
421- }
0 commit comments