Show:

Q_Exception Class

Extends Exception
Module: Q

Represents a complex exception thrown in Q. It may contain more details.

Constructor

Q_Exception

(
  • [$params=array()]
  • [$inputFields=array()]
  • [$code=null]
)

Parameters:

  • [$params=array()] Array optional

    Array of parameters for the exception. Used in the exception message, etc. To access them later, call $e->params() You can also provide a string here, which will then be the exception message.

  • [$inputFields=array()] Array optional

    Array of names of input fields to which the exception applies.

  • [$code=null] Array optional

    Optionally pass the error code here to override the default

Methods

$exception

(
  • $exception
)
Q_Exception

Construct a Q_Exception object from an Exception.

Parameters:

  • $exception Object

Returns:

__get

(
  • $param
)
Mixed

Parameters:

  • $param String

Returns:

Mixed:

__set

(
  • $param
  • $value
)

Parameters:

  • $param String
  • $value Mixed

add

(
  • $className
  • $message
  • [$rethrowDestClasses=array()]
  • [$baseClassName=null]
)
static

Registers a new exception class that extends Q_Exception

Parameters:

  • $className String

    The name of the exception class.

  • $message String

    The description of the error. Will be eval()-ed before rendering, so it can include references to parameters, such as $my_param.

  • [$rethrowDestClasses=array()] Array optional

    The name of the class that should handle this exception,

  • [$baseClassName=null] String optional

    Here you can pass the name of different base class than QException should it be thrown. Almost all catch() blocks in your code should use Q<em>Exception::rethrow($e, __CLASS</em></em>) as the first statement, if the exception might have to be re-thrown further down the stack.

getTraceAsStringEx

() String

Returns trace as string, can be overridden. Use this in your exception reporting. This is the default implementation.

Returns:

String:

getTraceEx

() Array

Returns the trace array, can be overridden. Use this in your exception reporting. This is the default implementation.

Returns:

Array:

inputFields

() Array

Returns the array of names of input fields the exception applies to.

Returns:

Array:

params

() Array

Returns the array of parameters the exception was created with.

Returns:

Array:

rethrow

(
  • $exception
  • $currentClass
)
static

Use in your catch() blocks if you think the exception might have to be thrown further down the stack.

Parameters:

  • $exception Exception

    The exception that was thrown. It is analyzed for whether it should be re-thrown.

  • $currentClass String

    If the $rethrowDestClasses was specified in Q_Exception::add when creating this exception's class, and it does not contain $currentClass, this function throws the exception again.

rethrowDestClasses

() Array

Returns an array of classes to rethrow to, if any.

Returns:

Array:

toArray

(
  • $exceptions
)
Array static

Converts an exception or array of exceptions to an array

Parameters:

  • $exceptions Exception | Array

    The exception object or array of exceptions to convert

Returns:

Array:

Properties

$baseClasses

Array protected

$code

String protected

$codes

Array protected

$inputFields

Array protected

$messages

Array protected

$params

Array protected

$rethrowDestClasses

Array protected

$trace

Array protected

$traceAsString

String protected