From c436d270b5ff435912074948a847f2f47c93bc1e Mon Sep 17 00:00:00 2001 From: leonard Date: Sun, 13 Dec 2020 19:44:23 +0100 Subject: [PATCH] Check for permissions in the render function --- aqua.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aqua.ts b/aqua.ts index bf87a0c..0552796 100644 --- a/aqua.ts +++ b/aqua.ts @@ -131,7 +131,11 @@ export default class Aqua { public async render(filePath: string): Promise { try { return this.textDecoder.decode(await Deno.readFile(filePath)); - }catch { + }catch(error) { + if (error instanceof Deno.errors.PermissionDenied) { + return "Please run your application with the '--allow-read' flag."; + } + return "Could not render file."; } }