mimicry/errors.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-09-08 19:52:21 +00:00
"use strict";
(function errorsPrivateClosure () {
class BasicError {
/**
* @param {String} path - path to the file that caused an error
* @param {String} originalName - original name of the loading file
* */
constructor(path, originalName) {
this.path = path;
this.originalName = originalName;
}
get message () {return "Unknown error about file " + this.originalName + " (" + this.path + ")"};
}
/**
* This error happens when Mimicry couldn't access a file
* */
class LoadError extends BasicError {
get message () {
return "Couldn't load file " + this.originalName +
" (" + this.path + ")";
}
}
/**
* This error happens when Mimicry couldn't evaluate a file
* */
class FileError extends BasicError {
constructor(path, originalName, message, line, col, nativeError) {
super(path, originalName);
this._message = message;
this._line = line;
this._col = col;
this._err = nativeError;
}
get message () {return this._message;}
get native () {return this._err;}
}
if (typeof module === 'object' && module.exports)
module.exports = {BasicError, LoadError, FileError};
else
window.__MimicryErrors__ = {BasicError, LoadError, FileError};
})();