From e703e51c9c09b22e3bcda9a1faf1e05897f60616 Mon Sep 17 00:00:00 2001 From: Minteck Date: Tue, 21 Dec 2021 15:25:09 +0100 Subject: Initial commit --- _mint/internal/StdIO.js | 7 +++++ _mint/internal/_exceptionManager.js | 57 +++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 _mint/internal/StdIO.js create mode 100644 _mint/internal/_exceptionManager.js (limited to '_mint/internal') diff --git a/_mint/internal/StdIO.js b/_mint/internal/StdIO.js new file mode 100644 index 0000000..3e35260 --- /dev/null +++ b/_mint/internal/StdIO.js @@ -0,0 +1,7 @@ +module.exports = { + stdout: { + writeln: (line) => { + console.log(line); + } + } +} \ No newline at end of file diff --git a/_mint/internal/_exceptionManager.js b/_mint/internal/_exceptionManager.js new file mode 100644 index 0000000..0f9cf7c --- /dev/null +++ b/_mint/internal/_exceptionManager.js @@ -0,0 +1,57 @@ +module.exports = class MintExceptionManagerError extends Error { + constructor(name, message, stack) { + super(message); + if (name.startsWith("mint.lang")) { + let type = name.substr(10); + if ( + type !== "CodeEvalException" + && type !== "OutOfBoundsException" + && type !== "VariableNotFoundException" + && type !== "InternalSyntaxException" + && type !== "IncompatibleTypesException" + && type !== "URIFunctionsException" + && type !== "CombinedFailuresException" + && type !== "InternalKernelException" + && type !== "InternalException" + ) { + this.name = "MintLangInternalException"; + } + } else if (name.startsWith("js.core.")) { + let type = name.substr(8); + switch (type) { + case "EvalError": + this.name = "MintLangCodeEvalException"; + break; + case "RangeError": + this.name = "MintLangOutOfBoundsException"; + break; + case "ReferenceError": + this.name = "MintLangVariableNotFoundException"; + break; + case "SyntaxError": + this.name = "MintLangInternalSyntaxException"; + break; + case "TypeError": + this.name = "MintLangIncompatibleTypesException"; + break; + case "URIError": + this.name = "MintLangURIFunctionsException"; + break; + case "AggregateError": + this.name = "MintLangCombinedFailuresException"; + break; + case "InternalError": + this.name = "MintLangInternalKernelException"; + break; + default: + this.name = "MintLangInternalException"; + break; + } + } else { + this.name = "MintLangInternalException"; + } + if (typeof stack !== "undefined") { + this.stack = stack; + } + } +} \ No newline at end of file -- cgit