mirror of
https://github.com/rjNemo/deno_hello
synced 2026-06-06 01:56:40 +00:00
refactor: cli
This commit is contained in:
parent
5a7dc56b51
commit
914ab13e74
1 changed files with 11 additions and 2 deletions
13
src/index.ts
13
src/index.ts
|
|
@ -1,4 +1,5 @@
|
||||||
import { readLines } from "https://deno.land/std@0.87.0/io/bufio.ts";
|
import { readLines } from "https://deno.land/std@0.87.0/io/bufio.ts";
|
||||||
|
import { ValidationError } from "./errors/exceptions.ts";
|
||||||
import { ID } from "./types/id.ts";
|
import { ID } from "./types/id.ts";
|
||||||
import { sayHello, sayRandomHello } from "./usecases/hello.ts";
|
import { sayHello, sayRandomHello } from "./usecases/hello.ts";
|
||||||
|
|
||||||
|
|
@ -17,8 +18,16 @@ const start = async () => {
|
||||||
} else if (value === "quit") {
|
} else if (value === "quit") {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
const id = new ID(parseInt(value, 10));
|
try {
|
||||||
console.log(sayHello(id));
|
const id = new ID(parseInt(value, 10));
|
||||||
|
console.log(sayHello(id));
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof ValidationError) {
|
||||||
|
console.error(error.message);
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue