Creating custom exceptions

Any project in the world may need exceptions. Exceptions are a modern and solid way of throwing errors for later handling them.

Creating new exception types is easy: it is just about deriving the $global.joopl.ExceptionBase** class:


$global.joopl.Samples.MyException = $def({
      $constructor: function() {
             this.$base.$ctor({ message: "My custom exception message" });
     $members: {
     $extends: $global.joopl.ExceptionBase

// Throwing the exception.
throw $new($global.joopl.Samples.MyException);

Last edited Feb 25, 2013 at 12:18 PM by MFidemraizer, version 1


No comments yet.