Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support exceptions as a way to trigger errors
- Add MantisException, ServiceException, and ClientException. - Add unhandled exception handler that forward to trigger error on error mode is display. - Force termination on case of E_USER_ERROR (aliased to ERROR in Mantis). This allows replacing trigger_error( …, ERROR) with throwing the appropriate exception while maintaining backward compatibility for UI code.
- Loading branch information
Showing
7 changed files
with
145 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* An exception that is triggered where the error is caused by | ||
* client input. | ||
*/ | ||
class ClientException extends MantisException { | ||
/** | ||
* Constructor | ||
* | ||
* @param string $p_message The internal non-localized error message. | ||
* @param integer $p_code The Mantis error code. | ||
* @param array $p_params Localized error message parameters. | ||
* @param Throwable $p_previous The inner exception. | ||
* @return void | ||
*/ | ||
function __construct( $p_message, $p_code, $p_params = array(), Throwable $p_previous = null ) { | ||
parent::__construct( $p_message, $p_code, $p_params, $p_previous ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
class MantisException extends Exception { | ||
protected $params; | ||
|
||
function __construct( $p_message, $p_code, $p_params = array(), Throwable $p_previous = null ) { | ||
parent::__construct( $p_message, $p_code, $p_previous ); | ||
$this->params = $p_params; | ||
} | ||
|
||
function getParams() { | ||
return $this->params; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* An exception that is triggered due to a Mantis error. | ||
*/ | ||
class ServiceException extends MantisException { | ||
/** | ||
* Constructor | ||
* | ||
* @param string $p_message The internal non-localized error message. | ||
* @param integer $p_code The Mantis error code. | ||
* @param array $p_params Localized error message parameters. | ||
* @param Throwable $p_previous The inner exception. | ||
* @return void | ||
*/ | ||
function __construct( $p_message, $p_code, $p_params = array(), Throwable $p_previous = null ) { | ||
parent::__construct( $p_message, $p_code, $p_params, $p_previous ); | ||
} | ||
} |