diff --git a/packages/forest-cloud/src/services/bootstrap.ts b/packages/forest-cloud/src/services/bootstrap.ts index 367eb647a4..eb25c59c4c 100644 --- a/packages/forest-cloud/src/services/bootstrap.ts +++ b/packages/forest-cloud/src/services/bootstrap.ts @@ -68,8 +68,12 @@ export default async function bootstrap( const datasources = await httpServer.getDatasources(); await updateTypings(datasources, paths); - } catch (error) { + } catch (e) { + const error = e as Error; const potentialErrorMessage = await tryToClearBootstrap(paths); - throw new BusinessError(`Bootstrap failed: ${error.message}.${potentialErrorMessage || ''}`); + + throw new BusinessError( + `Bootstrap failed: ${error.message}. ${potentialErrorMessage || ''}${error.stack}`, + ); } } diff --git a/packages/forest-cloud/test/services/bootstrap.unit.test.ts b/packages/forest-cloud/test/services/bootstrap.unit.test.ts index b729cbb952..43772801f3 100644 --- a/packages/forest-cloud/test/services/bootstrap.unit.test.ts +++ b/packages/forest-cloud/test/services/bootstrap.unit.test.ts @@ -72,9 +72,8 @@ describe('bootstrap', () => { jest.spyOn(fs, 'existsSync').mockReturnValue(false); const httpServer = new HttpServer('', '', ''); const path = new BootstrapPathManager('', ''); - HttpServer.downloadCloudCustomizerTemplate = jest - .fn() - .mockRejectedValue(new Error('Failed')); + const error = new Error('Failed'); + HttpServer.downloadCloudCustomizerTemplate = jest.fn().mockRejectedValue(error); await expect( bootstrap( @@ -82,7 +81,7 @@ describe('bootstrap', () => { httpServer, path, ), - ).rejects.toEqual(new BusinessError('Bootstrap failed: Failed.')); + ).rejects.toEqual(new BusinessError(`Bootstrap failed: Failed. ${error.stack}`)); }); describe('If there is an error when trying to clear the bootstrap', () => { @@ -90,11 +89,10 @@ describe('bootstrap', () => { jest.spyOn(fs, 'existsSync').mockReturnValue(false); const httpServer = new HttpServer('', '', ''); const path = new BootstrapPathManager('', ''); - HttpServer.downloadCloudCustomizerTemplate = jest - .fn() - .mockRejectedValue(new Error('Failed')); + const error = new Error('Failed'); + HttpServer.downloadCloudCustomizerTemplate = jest.fn().mockRejectedValue(error); // throw error when trying to clear - jest.spyOn(fsP, 'rm').mockRejectedValue(new Error('Failed')); + jest.spyOn(fsP, 'rm').mockRejectedValue(new Error('Cannot remove file')); await expect( bootstrap( @@ -104,7 +102,7 @@ describe('bootstrap', () => { ), ).rejects.toEqual( new BusinessError( - 'Bootstrap failed: Failed.\nPlease remove "forest-cloud" folder and re-run bootstrap command.', + `Bootstrap failed: Failed. \nPlease remove "forest-cloud" folder and re-run bootstrap command.${error.stack}`, ), ); });