Skip to content

Commit

Permalink
feat: add new error type and exit when needed (#487)
Browse files Browse the repository at this point in the history
This PR adds UnresolvableError type, when something like docker is not running or is wrong version occurred.

Signed-off-by: georgi-l95 <[email protected]>
  • Loading branch information
georgi-l95 authored Jan 8, 2024
1 parent f8cd760 commit fbe7e14
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/controller/StateController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class StateController implements IOBserver{
if (event === EventType.Finish) {
await this.transitionToNextState();
} else {
if (event === EventType.UnknownError) {
if (event === EventType.UnknownError || event === EventType.UnresolvableError) {
await new CleanUpState().onStart();
process.exit(1);
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/state/InitState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export class InitState implements IState{
// Check if docker is running and it's the correct version
const isCorrectDockerComposeVersion = await this.dockerService.isCorrectDockerComposeVersion();
const isDockerStarted = await this.dockerService.checkDocker();
if (!(isCorrectDockerComposeVersion && isDockerStarted)) {
this.observer!.update(EventType.UnresolvableError);
return;
}
await this.dockerService.isPortInUse(NECESSARY_PORTS.concat(OPTIONAL_PORTS));

this.logger.info(`Setting configuration for ${this.cliOptions.network} network with latest images on host ${this.cliOptions.host} with dev mode turned ${this.cliOptions.devMode ? 'on' : 'off'} using ${this.cliOptions.fullMode? 'full': 'turbo'} mode in ${this.cliOptions.multiNode? 'multi' : 'single'} node configuration...`, this.stateName);
Expand Down
3 changes: 2 additions & 1 deletion src/types/EventType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
export enum EventType{
Finish,
DockerError,
UnknownError
UnknownError,
UnresolvableError
}

0 comments on commit fbe7e14

Please sign in to comment.