File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed
Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import {logger} from '../wrapper/loggerConfig';
22import * as fs from 'fs' ;
33import { finished } from 'stream/promises' ;
44import { Client } from "./Client" ;
5+ import { CxError } from "../errors/CxError" ;
56
67export class AstClient {
78 private client : Client ;
@@ -20,7 +21,7 @@ export class AstClient {
2021 logger . info ( `Download completed successfully. File saved to: ${ outputPath } ` ) ;
2122 } catch ( error ) {
2223 logger . error ( `Error downloading file from ${ url } : ${ error . message || error } ` ) ;
23- throw error ;
24+ throw new CxError ( error . message || error ) ;
2425 } finally {
2526 writer . close ( ) ;
2627 }
Original file line number Diff line number Diff line change 1+ export class CxError extends Error {
2+ constructor ( message : string ) {
3+ super ( message ) ;
4+ this . name = "CxError" ;
5+ }
6+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import * as tar from 'tar';
55import * as unzipper from 'unzipper' ;
66import { logger } from "../wrapper/loggerConfig" ;
77import { AstClient } from "../client/AstClient" ;
8+ import { CxError } from "../errors/CxError" ;
89
910const linuxOS = 'linux' ;
1011const macOS = 'darwin' ;
@@ -41,7 +42,7 @@ export class CxInstaller {
4142 const platformData = CxInstaller . PLATFORMS [ this . platform ] ;
4243
4344 if ( ! platformData ) {
44- throw new Error ( 'Unsupported platform or architecture' ) ;
45+ throw new CxError ( 'Unsupported platform or architecture' ) ;
4546 }
4647
4748 const architecture = this . getArchitecture ( ) ;
@@ -103,7 +104,10 @@ export class CxInstaller {
103104 logger . info ( 'Extracted CLI to:' , this . resourceDirPath ) ;
104105 } catch ( error ) {
105106 logger . error ( 'Error during installation:' , error ) ;
106- process . exit ( 1 ) ;
107+ if ( error instanceof CxError ) {
108+ logger . error ( 'Error message:' , error . message ) ;
109+ process . exit ( 1 ) ;
110+ }
107111 }
108112 }
109113
You can’t perform that action at this time.
0 commit comments