From 101bab2d15b1ed538318b3c49199ea0130e917c4 Mon Sep 17 00:00:00 2001 From: mt3571 Date: Mon, 30 Nov 2020 11:07:05 +0000 Subject: [PATCH] Added in another error check --- src/core/operations/ManchesterEncode.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/operations/ManchesterEncode.mjs b/src/core/operations/ManchesterEncode.mjs index 55dc62fe..765694f9 100644 --- a/src/core/operations/ManchesterEncode.mjs +++ b/src/core/operations/ManchesterEncode.mjs @@ -5,6 +5,7 @@ */ import Operation from "../Operation.mjs"; +import OperationError from "../errors/OperationError.mjs"; /** * Manchester encoding operation @@ -40,9 +41,11 @@ class ManchesterEncode extends Operation { if (bit == 0){ encoding.push(1); encoding.push(0); - } else { + } else if (bit == 1){ encoding.push(0); encoding.push(1); + } else { + throw new OperationError(`Invalid input character ${bit}. Input should be in binary.`); } }