@@ -8,7 +8,7 @@ import type {
88 SDKFramework ,
99 TargetLanguage ,
1010} from '../../../schema' ;
11- import { getErrorMessage } from '../../errors' ;
11+ import { DependencyCheckError , GitInitError , toError } from '../../errors' ;
1212import { checkCreateDependencies } from '../../external-requirements' ;
1313import { initGitRepo , setupPythonProject , writeEnvFile , writeGitignore } from '../../operations' ;
1414import { createConfigBundleForAgent } from '../../operations/agent/config-bundle-defaults' ;
@@ -57,7 +57,7 @@ export async function createProject(options: CreateProjectOptions): Promise<Crea
5757
5858 // Fail on errors
5959 if ( ! depCheck . passed ) {
60- return { success : false , error : depCheck . errors . join ( '\n' ) , warnings : depWarnings } ;
60+ return { success : false , error : new DependencyCheckError ( depCheck . errors ) , warnings : depWarnings } ;
6161 }
6262 }
6363
@@ -93,7 +93,11 @@ export async function createProject(options: CreateProjectOptions): Promise<Crea
9393 const gitResult = await initGitRepo ( projectRoot ) ;
9494 if ( gitResult . status === 'error' ) {
9595 onProgress ?.( 'Initialize git repository' , 'error' ) ;
96- return { success : false , error : gitResult . message , warnings : depWarnings } ;
96+ return {
97+ success : false ,
98+ error : new GitInitError ( gitResult . message ?? 'Git initialization failed' ) ,
99+ warnings : depWarnings ,
100+ } ;
97101 }
98102 onProgress ?.( 'Initialize git repository' , 'done' ) ;
99103 }
@@ -104,7 +108,7 @@ export async function createProject(options: CreateProjectOptions): Promise<Crea
104108 warnings : depWarnings . length > 0 ? depWarnings : undefined ,
105109 } ;
106110 } catch ( err ) {
107- return { success : false , error : getErrorMessage ( err ) , warnings : depWarnings } ;
111+ return { success : false , error : toError ( err ) , warnings : depWarnings } ;
108112 }
109113}
110114
@@ -174,7 +178,7 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
174178
175179 // Fail on errors
176180 if ( ! depCheck . passed ) {
177- return { success : false , error : depCheck . errors . join ( '\n' ) , warnings : depWarnings } ;
181+ return { success : false , error : new DependencyCheckError ( depCheck . errors ) , warnings : depWarnings } ;
178182 }
179183
180184 // First create the base project (skip dependency check since we already did it)
@@ -187,7 +191,6 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
187191 onProgress,
188192 } ) ;
189193 if ( ! projectResult . success ) {
190- // Merge warnings from both checks
191194 const allWarnings = [ ...depWarnings , ...( projectResult . warnings ?? [ ] ) ] ;
192195 return { ...projectResult , warnings : allWarnings . length > 0 ? allWarnings : undefined } ;
193196 }
@@ -207,7 +210,7 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
207210 } ) ;
208211 if ( ! importResult . success ) {
209212 onProgress ?.( 'Import agent from Bedrock' , 'error' ) ;
210- return { success : false , error : importResult . error , warnings : depWarnings } ;
213+ return { ... importResult , warnings : depWarnings . length > 0 ? depWarnings : undefined } ;
211214 }
212215 onProgress ?.( 'Import agent from Bedrock' , 'done' ) ;
213216 return {
@@ -217,7 +220,7 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
217220 warnings : depWarnings . length > 0 ? depWarnings : undefined ,
218221 } ;
219222 } catch ( err ) {
220- return { success : false , error : getErrorMessage ( err ) , warnings : depWarnings } ;
223+ return { success : false , error : toError ( err ) , warnings : depWarnings } ;
221224 }
222225 }
223226
@@ -310,7 +313,7 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
310313 warnings : depWarnings . length > 0 ? depWarnings : undefined ,
311314 } ;
312315 } catch ( err ) {
313- return { success : false , error : getErrorMessage ( err ) , warnings : depWarnings } ;
316+ return { success : false , error : toError ( err ) , warnings : depWarnings } ;
314317 }
315318}
316319
0 commit comments