@@ -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,11 @@ 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 {
61+ success : false ,
62+ error : new DependencyCheckError ( depCheck . errors ) ,
63+ warnings : depWarnings . length > 0 ? depWarnings : undefined ,
64+ } ;
6165 }
6266 }
6367
@@ -93,7 +97,11 @@ export async function createProject(options: CreateProjectOptions): Promise<Crea
9397 const gitResult = await initGitRepo ( projectRoot ) ;
9498 if ( gitResult . status === 'error' ) {
9599 onProgress ?.( 'Initialize git repository' , 'error' ) ;
96- return { success : false , error : gitResult . message , warnings : depWarnings } ;
100+ return {
101+ success : false ,
102+ error : new GitInitError ( gitResult . message ?? 'Git initialization failed' ) ,
103+ warnings : depWarnings . length > 0 ? depWarnings : undefined ,
104+ } ;
97105 }
98106 onProgress ?.( 'Initialize git repository' , 'done' ) ;
99107 }
@@ -104,7 +112,7 @@ export async function createProject(options: CreateProjectOptions): Promise<Crea
104112 warnings : depWarnings . length > 0 ? depWarnings : undefined ,
105113 } ;
106114 } catch ( err ) {
107- return { success : false , error : getErrorMessage ( err ) , warnings : depWarnings } ;
115+ return { success : false , error : toError ( err ) , warnings : depWarnings . length > 0 ? depWarnings : undefined } ;
108116 }
109117}
110118
@@ -174,7 +182,11 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
174182
175183 // Fail on errors
176184 if ( ! depCheck . passed ) {
177- return { success : false , error : depCheck . errors . join ( '\n' ) , warnings : depWarnings } ;
185+ return {
186+ success : false ,
187+ error : new DependencyCheckError ( depCheck . errors ) ,
188+ warnings : depWarnings . length > 0 ? depWarnings : undefined ,
189+ } ;
178190 }
179191
180192 // First create the base project (skip dependency check since we already did it)
@@ -187,9 +199,7 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
187199 onProgress,
188200 } ) ;
189201 if ( ! projectResult . success ) {
190- // Merge warnings from both checks
191- const allWarnings = [ ...depWarnings , ...( projectResult . warnings ?? [ ] ) ] ;
192- return { ...projectResult , warnings : allWarnings . length > 0 ? allWarnings : undefined } ;
202+ return { ...projectResult , warnings : depWarnings . length > 0 ? depWarnings : projectResult . warnings } ;
193203 }
194204
195205 // Import path: delegate to executeImportAgent after project scaffolding
@@ -207,7 +217,7 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
207217 } ) ;
208218 if ( ! importResult . success ) {
209219 onProgress ?.( 'Import agent from Bedrock' , 'error' ) ;
210- return { success : false , error : importResult . error , warnings : depWarnings } ;
220+ return importResult ;
211221 }
212222 onProgress ?.( 'Import agent from Bedrock' , 'done' ) ;
213223 return {
@@ -217,7 +227,7 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
217227 warnings : depWarnings . length > 0 ? depWarnings : undefined ,
218228 } ;
219229 } catch ( err ) {
220- return { success : false , error : getErrorMessage ( err ) , warnings : depWarnings } ;
230+ return { success : false , error : toError ( err ) , warnings : depWarnings . length > 0 ? depWarnings : undefined } ;
221231 }
222232 }
223233
@@ -310,7 +320,7 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
310320 warnings : depWarnings . length > 0 ? depWarnings : undefined ,
311321 } ;
312322 } catch ( err ) {
313- return { success : false , error : getErrorMessage ( err ) , warnings : depWarnings } ;
323+ return { success : false , error : toError ( err ) , warnings : depWarnings . length > 0 ? depWarnings : undefined } ;
314324 }
315325}
316326
0 commit comments