Errors Solutions


Nexss PROGRAMMER also shows possible solutions to the issue you may come up during development. You can also configure your own errors solutions definitions (regexp or string) in the _nexss.yml config file eg:

Syntax

  • String - any string to be matched - {"pattern":"solution"}
  • Capturing Group - string + one (*.?) - when found \<found1> will be replaced.
  • Named Groups - (?\<found1>.*?) some string (?\<found2>.*?) - more info about named groups here, or example of config: Java Errors Solutions Example
  • Function - you can write own functions for error solutions (like automatic fixes etc.). Function can take 4 parameters: solution(errorBody, filename, arrayMatch, langConfig)

    • errorBody - is the error returned by the compiler
    • filename - is the filename of the file coused the error
    • arrayMatch - is the capturing group information
    • langConfig - is the whole language configuration as object

Example of 3 different error solutions possible as above

module.exports = {
  "ModuleNotFoundError:":
    "nexss py install <module here> OR pip3 install <module here>",
  "ModuleNotFoundError: No module named '(.*?)'":
    "nexss py install <module> OR pip3 install <module>",
  "ModuleNotFoundError: No module named '(?<found1>.*?)'":
    "nexss py install <found1> OR pip3 install <found1>",
  'invalid command name "(?<command>.*?)".*\\(file "(?<file>.*?)" line (?<line>.*?)\\)':
    "Check the word/command '<command>' line: <line> in the file: <file>",
  'invalid command name "(?<found1>.*?)"': function(
    errorBody,
    filename,
    arrayMatch,
    languageConfig
  ) {
    console.log(
      "Example of function as error solution",
      errorBody,
      filename,
      arrayMatch,
      languageConfig
    );
  }
};

"error (.*?)":"solution text " or if you will not include (.*?) then won't be replaced.

Example String: "mystring to match" : "this is the solution"

Example Capturing Group: "xyz '(.*?)' abc" - this will find eg "xyz 'myerror' abc" - the \<found1> will have value myerror

Example Named Group: "symbol: class (?\<anyname>.*?)\r\n": "Check the '\<anyname>' word.."

Language Config Example

Each programming language in the Nexss Programmer has own file with errors definition eg for Java: C:/Users/mapoart/.nexss/languages/language_java.git/nexss.java.errors.js and looks like below:

module.exports = {
  "symbol:   class (?<found1>.*?)\\r\\n": "Check the '<found1>' word..",
  "Could not find or load main class (.*?)":
    "Please make sure class name is the same as filename and starts with uppercase letter.",
  "variable inline might not have been initialized": `Variable is declared but not initialized. eg. string x; but must be string x=""`,
  "Caused by: java.lang.ClassNotFoundException:(.*?)": `Nexss Programmer has CLASSPATH specifiend to the ./lib folder. Please go to https://github.com/nexssp/language_java for more details.`,
  "has been compiled by a more recent version of the Java Runtime \\(class file version (?<found1>.*?)\\), this version of the Java Runtime only recognizes class file versions up to (?<found2>.*?)\r\n":
    "Java Compiler (javac) <found1> is different then your Java Runtime (java) <found2>. For more details please go to: https://github.com/nexssp/language_java/wiki/java.lang.UnsupportedClassVersionError-issue"
};

Custom for each project

You can add or ovewrite already defined errors in the _nexss.yml like example below. Below will overwrite the same error solution as defined on the language so you can have possibility to display different error solutions per projects/packages.

errors:
  "address already in use :::(.*?)\r\n": "Find process and kill it by: nexss ps find port <found1> && nexss ps stop <founded pid>"

Replacer

You can add replacer which will replace strings, for example if you define error and in capture group you have package function and you want to install package, you can provide package name not function.

languageConfig.replacer = __dirname + "/nexss.haskell.replacer.js"; // replace strings in errors solutions

and file looks like:

so in this example if in solution 'Data.Aeson' will appear it will be replaced by 'aeson'. Example is from Haskell Lanugage.

module.exports = {
  "Data.Aeson": "aeson"
};