diff --git a/src/index.ts b/src/index.ts index 009cca3..97c15b2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ 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 { sayHello, sayRandomHello } from "./usecases/hello.ts"; @@ -17,8 +18,16 @@ const start = async () => { } else if (value === "quit") { return; } else { - const id = new ID(parseInt(value, 10)); - console.log(sayHello(id)); + try { + const id = new ID(parseInt(value, 10)); + console.log(sayHello(id)); + } catch (error) { + if (error instanceof ValidationError) { + console.error(error.message); + } else { + throw error; + } + } } } };