public static function build(array $constructorArguments = array(), $additionalProperties = array())
    {
        $constructorDefaults = array('message' => null, 'code' => null, 'previous' => null);
        $constructorArguments = array_merge($constructorDefaults, $constructorArguments);

        $message = self::prepareMessage($constructorArguments['message'], $additionalProperties);
        $code = self::prepareCode($constructorArguments['code']);
        $previous = $constructorArguments['previous'];

        $e = new static($message, $code, $previous);

        $e = self::addAdditionalProperties($e, $additionalProperties);

        return $e;
    }
public static function build(array $constructorArguments = array(), $additionalProperties = array())
    {
        $constructorDefaults = array('message' => null, 'code' => null, 'previous' => null);
        $constructorArguments = array_merge($constructorDefaults, $constructorArguments);

        $message = self::prepareMessage($constructorArguments['message'], $additionalProperties);
        $code = self::prepareCode($constructorArguments['code']);
        $previous = $constructorArguments['previous'];

        $e = new static($message, $code, $previous);

        $e = self::addAdditionalProperties($e, $additionalProperties);

        return $e;
    }
public static function build ( array $ constructorArguments = array ( ) , $ additionalProperties = array ( ) ) { $ constructorDefaults = array ( 'message' => null , 'code' => null , 'previous' => null ) ; $ constructorArguments = array_merge ( $ constructorDefaults , $ constructorArguments ) ; $ message = self :: prepareMessage ( $ constructorArguments [ 'message' ] , $ additionalProperties ) ; $ code = self :: prepareCode ( $ constructorArguments [ 'code' ] ) ; $ previous = $ constructorArguments [ 'previous' ] ; $ e = new static ( $ message , $ code , $ previous ) ; $ e = self :: addAdditionalProperties ( $ e , $ additionalProperties ) ; return $ e ; }
Helper method to prepare all but the most complex exceptions

Pass in an array containing any or all of the following keys
- message (string)
- code (int)
- previous (\Exception)

If you don't pass in a 'message' or a 'code' then the method will attempt to get these from the exception class
getDefaultMessage or getDefaultCode methods, respectively.

If no message is prepared, then we throw a \RuntimeException... There's no excuse for not including a useful
message!

If no code if prepared, then 500 is used

@param array $constructorArguments [optional] Arguments to be passed to the constructor
@param array $additionalProperties [optional] Additional p

@return static

@throws \RuntimeException if no message can be prepared... There's no excuse for not including a useful message!
Helper method to prepare all but the most complex exceptions