@@ -27,12 +27,12 @@ import { SourceType } from '../odo/config';
2727import { ComponentKind , ComponentTypeAdapter , DevfileComponentType , ImageStreamTag , isDevfileComponent , isImageStreamTag } from '../odo/componentType' ;
2828import { Url } from '../odo/url' ;
2929import { ComponentDescription , StarterProjectDescription } from '../odo/catalog' ;
30+ import { isStarterProject , StarterProject } from '../odo/componentTypeDescription' ;
3031import path = require( 'path' ) ;
31-
3232import globby = require( 'globby' ) ;
3333import treeKill = require( 'tree-kill' ) ;
3434import fs = require( 'fs-extra' ) ;
35- import { isStarterProject , StarterProject } from '../odo/componentTypeDescription ' ;
35+ import { NewComponentCommandProps } from '../telemetry ' ;
3636
3737const waitPort = require ( 'wait-port' ) ;
3838
@@ -111,7 +111,7 @@ export class Component extends OpenShiftItem {
111111 static async create ( application : OpenShiftApplication ) : Promise < string > {
112112 if ( ! application ) return null ;
113113
114- return Component . createFromLocal ( application ) . catch ( ( err ) => Promise . reject ( new VsCommandError ( `Failed to create Component with error ' ${ err } '` , 'Failed to create Component with error' ) ) ) ;
114+ return Component . createFromLocal ( application ) ;
115115 }
116116
117117 @vsCommand ( 'openshift.component.delete' , true )
@@ -684,34 +684,45 @@ export class Component extends OpenShiftItem {
684684 }
685685
686686 const refreshComponentsView = workspace . getWorkspaceFolder ( folder ) ;
687-
688- await Progress . execFunctionWithProgress (
689- `Creating new Component '${ componentName } '` ,
690- ( ) => Component . odo . createComponentFromFolder (
691- application ,
692- componentType ? componentType . name : undefined , // in case of using existing devfile
693- componentType ? componentType . version : undefined ,
694- componentName ,
695- folder ,
696- createStarter ,
697- useExistingDevfile
698- )
699- ) ;
700-
701- // when creating component based on existing workspace folder refresh components view
702- if ( refreshComponentsView ) {
703- commands . executeCommand ( 'openshift.componentsView.refresh' ) ;
704- }
705-
706- const result :any = new String ( `Component '${ componentName } ' successfully created. To deploy it on cluster, perform 'Push' action.` ) ;
707- result . properties = {
687+ const creatComponentProperties : NewComponentCommandProps = {
708688 'component_kind' : componentType ?. version ? ComponentKind . S2I : ComponentKind . DEVFILE ,
709689 'component_type' : componentType ?. name ,
710690 'component_version' : componentType ?. version ,
711691 'starter_project' : createStarter ,
712692 'use_existing_devfile' : useExistingDevfile ,
713693 } ;
714- return result ;
694+ try {
695+ await Progress . execFunctionWithProgress (
696+ `Creating new Component '${ componentName } '` ,
697+ ( ) => Component . odo . createComponentFromFolder (
698+ application ,
699+ componentType ? componentType . name : undefined , // in case of using existing devfile
700+ componentType ? componentType . version : undefined ,
701+ componentName ,
702+ folder ,
703+ createStarter ,
704+ useExistingDevfile
705+ )
706+ ) ;
707+
708+ // when creating component based on existing workspace folder refresh components view
709+ if ( refreshComponentsView ) {
710+ commands . executeCommand ( 'openshift.componentsView.refresh' ) ;
711+ }
712+
713+ const result :any = new String ( `Component '${ componentName } ' successfully created. To deploy it on cluster, perform 'Push' action.` ) ;
714+ result . properties = creatComponentProperties ;
715+ return result ;
716+ } catch ( err ) {
717+ if ( err instanceof VsCommandError ) {
718+ throw new VsCommandError (
719+ `Error occurred while creating Component '${ componentName } ': ${ err . message } ` ,
720+ `Error occurred while creating Component: ${ err . telemetryMessage } ` , err ,
721+ creatComponentProperties
722+ ) ;
723+ }
724+ throw err ;
725+ }
715726 }
716727
717728 @vsCommand ( 'openshift.component.createFromGit' )
0 commit comments