CryptoMañana Documentation

The Object-Oriented PHP Cryptography Framework

Cryptographic Model Exceptions

    The software framework supports custom exceptions at the developed cryptography model. They are needed for the existing component realizations and for the future ones to come. The developer can use them in the cryptographic context for marking process, protocol or other errors.

    The CryptoMañana (CryptoManana) cryptography framework provides all available cryptographic model exceptions at the \CryptoManana\Exceptions namespace. Here is a list of all custom error components:

    Each error object extends the AbstractException base exception specification and is derived from the default PHP \Exception object. This type of exception object is fully configurable before throwing (in contrast to the default one) and has an INTERNAL_CODE constant for the actual framework error, that is said to the object’s code property. You can get the framework internal code via the getFrameworkErrorCode() even if you decide to add a custom error code to the object. The following custom methods are available:

getFrameworkErrorCode() // gets the internal error code
setMessage() // set a custom message
setCode() // set a custom code
setFile() // set a custom file name
setLine() // set a custom line

    This type of component has 1 public constant available:

INTERNAL_CODE // the framework internal error code

    Here is a simple example for the usage of this type of secure data service component:

use CryptoManana\Exceptions\CryptographyException;

$exception = new CryptographyException();

$exception->setCode(500)
    ->setMessage('Wrong key at server!')
    ->setLine(3)
    ->setFile(__FILE__);

echo 'Framework Error Code: ' . $exception->getFrameworkErrorCode() . '<br>';
echo 'Error Code: ' . $exception->getCode() . '<br>';
echo 'Error Message: ' . $exception->getMessage() . '<br>';
echo 'Error Line: ' . $exception->getLine() . '<br>';
echo 'Error File: ' . $exception->getFile() . '<br>';

echo 'Throwing it for testing purposes: ' . '<br>';

throw $exception;

The Object Hierarchy

    The internal components’ hierarchy is visualized as a technical diagram and can be seen in Figure 1.

The Framework Exception Hierarchy

Figure 1: The framework exception components hierarchy.

    For more information about the capabilities of the components, please see the technical documentation for \CryptoManana\Exceptions namespace.

Previous Next