PP.InterfaceNotImpException

Syntax

InterfaceNotImpException(message: String, self: Object);

Parameters

message. Message passed to exception. This is an optional parameter, by default its value is not defined.

self. Exception source. This is an optional parameter, by default its value is not defined.

Description

The InterfaceNotImpException method returns a formatted message about the exception InterfaceNotImpException.

Comments

This method returns a String value in the following format: InterfaceNotImpException. Source: [Exception source] Message: [Message to be shown].

The  InterfaceNotImpException exception is used if the object does not implement interface.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Create a new namespace, interface, class that implements this interface, but do not implement method defined in the interface:

// Determine a new namespace inside PP
PP.ArithmeticNamespace = {};
PP.initNamespace(PP.ArithmeticNamespace, "PP.ArithmeticNamespace");
// Determine an interface without implementation in the created namespace
(PP.ArithmeticNamespace.OperationInterface = function () {
    var operationInterface = PP.ArithmeticNamespace.OperationInterface;
    PP.initInterface(operationInterface, "OperationInterface");
    operationInterface.calc = PP.ClassMembers.Method;
})();
/* Create the Calculator class inherited from the PP.Object class
  and implementing the PP.ArithmeticNamespace.OperationInterface interface */
PP.ArithmeticNamespace.Calculator = function (settings) {
    PP.ArithmeticNamespace.Calculator.base.constructor.call(this, settings);
};
PP.initClass(PP.ArithmeticNamespace.Calculator, PP.Object, "PP.ArithmeticNamespace.Calculator",
    PP.ArithmeticNamespace.OperationInterface);
// Create an instance of the PP.Calculator class
var calculator = new PP.ArithmeticNamespace.Calculator();
/* Determine whether the PP.ArithmeticNamespace.Calculator class
   implements the PP.ArithmeticNamespace.OperationInterface interface */
var isInterfaceOf = PP.isInterfaceOf(calculator, PP.ArithmeticNamespace.OperationInterface, False);
if (isInterfaceOf) {
    console.log("The PP.ArithmeticNamespace.OperationInterface interface is not implemented");
} else {
    var msg = "The PP.ArithmeticNamespace.OperationInterface interface is not implemented";
    // Get an error message
    var exception = PP.InterfaceNotImpException(msg, calculator);
    console.log(exception);
};

After executing the example the following objects are created: ArithmeticNamespace namespace, OperationInterface interface, and the Calculator class that implements this interface. As this class does not implement the calc method determined in the interface, the browser console displays an error message:

InterfaceNotImpException. Source: Calculator Message: The PP.ArithmeticNamespace.OperationInterface interface is not implemented

See also:

PP