Question about errors vs exceptions

Posted on
  • Sorry for the barrage of questions, I hope it's OK.

    Any wisdom about jsError vs. jsException? I see a bit of a mix in the codebase for situations where, for example, a callback argument is not actually a function, or a password is required but not provided.

    My intuition would be to use an error when the program code is incorrect, such as not providing required arguments and to use exceptions when a dynamic error state is encountered that may be fixed, such as trying to send on a socket and the socket got closed in the meantime.

  • We should really move fully over to jsException(JSET_ERROR and kill jsError eventually... jsError was used before Espruino had Exceptions, and it's not part of the JavaScript spec at all.

    I'm afraid it's just a bit of a hangover. There are other error types though - TypeError (invalid arguments) and InternalError (stuff that went wrong in Espruino) might be the most useful.

  • Ooops, I've been going the other direction, I'm glad I asked :-)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Question about errors vs exceptions

Posted by Avatar for tve @tve

Actions