/**
* A set of conventional error, exception and warning messages.
* Organized by type and then hierarchically according to specificity, from `SPL`, python and node.js
* @version 0.0.1
*/
/*_______________________________________________________________
*
* Parameter Error Messages
*/
const INVALID_ARGUMENT_EXCEPTION = 'Invalid Argument Exception'
const MISSING_ARGUMENT = 'Missing Required Argument'
const INVALID_ARGUMENT_TYPE = 'Invalid Argument Type'
const AMBIGUOUS_ARGUMENT = 'Ambiguous Argument'
const INVALID_ARGUMENT_VALUE = 'Invalid Argument Value'
const MISSING_REQUIRED_CALLBACK = 'Invalid Callback'
const INVALID_CONTEXT = 'Invalid Context'
const INVALID_URI = 'Invalid URI'
/*_______________________________________________________________
*
* Module Error Messages
*/
const IMPORT_ERROR = 'Import Error'
/*_______________________________________________________________
*
* Function Error Messages
*/
const BAD_FUNCTION_CALL = 'Bad Function Call'
const BAD_METHOD_CALL = 'Bad Method Call'
/*_______________________________________________________________
*
* Table Error Messages
*/
const LOOKUP_ERROR = 'Lookup Error'
/*_______________________________________________________________
*
* Value Error Messages
*/
const OUT_OF_RANGE = 'Out of Range'
const OUT_OF_BOUNDS = 'Out of Bounds'
const DOMAIN_EXCEPTION = 'Domain Exception'
const UNEXPECTED_VALUE = 'Unexpected Value'
const RANGE_EXCEPTION = 'Range Exception'
const LENGTH_EXCEPTION = 'Length Exception'
/*_______________________________________________________________
*
* Logic Error Messages
*/
const ARITHMETIC_ERROR = 'Arithmetic Error'
const LOGIC_EXCEPTION = 'Logic Exception'
/*_______________________________________________________________
*
* Reference Error Messages
*/
const REFERENCE_ERROR = 'Reference Error'
/*_______________________________________________________________
*
* Assertion Error Messages
*/
const ASSERTION_ERROR = 'Assertion Error'
/*_______________________________________________________________
*
* Runtime Error Messages
*/
const RUNTIME_EXCEPTION = 'Runtime Exception'
const SCRIPT_TIMEOUT_ERROR = 'Script Timeout'
/*_______________________________________________________________
*
* Dom-specific Error Messages
*/
const INVALID_NODE_TYPE_VALUE = 'Invalid Node Type Value'
const UNEXPECTED_NODE_TYPE = 'Unexpected Node Type'
// sample usage
// () => {
// try {
// // ...
// } catch( e ) {
// throw new Error( INVALID_ARGUMENT_TYPE )
// }
// }
// try {
//
// } catch ( e ) {
// throw new Error( BAD_METHOD_CALL + ': ' + e.getMessage() )
// }
<?php
/*_______________________________________________________________
*
* Parameter Error Messages
*/
define('INVALID_ARGUMENT_EXCEPTION', 'Invalid Argument Exception');
define('MISSING_ARGUMENT', 'Missing Required Argument');
define('INVALID_ARGUMENT_TYPE', 'Invalid Argument Type' );
define('AMBIGUOUS_ARGUMENT', 'Ambiguous Argument');
define('INVALID_ARGUMENT_VALUE', 'Invalid Argument Value');
define('MISSING_REQUIRED_CALLBACK', 'Invalid Callback');
define('INVALID_CONTEXT', 'Invalid Context');
define('INVALID_URI', 'Invalid URI');
/*_______________________________________________________________
*
* Module Error Messages
*/
define('IMPORT_ERROR', 'Import Error');
/*_______________________________________________________________
*
* Function Error Messages
*/
define('BAD_FUNCTION_CALL', 'Bad Function Call');
define('BAD_METHOD_CALL', 'Bad Method Call');
/*_______________________________________________________________
*
* Table Error Messages
*/
define('LOOKUP_ERROR', 'Lookup Error');
/*_______________________________________________________________
*
* Value Error Messages
*/
define('OUT_OF_RANGE', 'Out of Range');
define('OUT_OF_BOUNDS', 'Out of Bounds');
define('DOMAIN_EXCEPTION', 'Domain Exception');
define('UNEXPECTED_VALUE', 'Unexpected Value');
define('RANGE_EXCEPTION', 'Range Exception');
define('LENGTH_EXCEPTION', 'Length Exception');
/*_______________________________________________________________
*
* Logic Error Messages
*/
define('ARITHMETIC_ERROR', 'Arithmetic Error');
define('LOGIC_EXCEPTION', 'Logic Exception');
/*_______________________________________________________________
*
* Reference Error Messages
*/
define('REFERENCE_ERROR', 'Reference Error');
/*_______________________________________________________________
*
* Assertion Error Messages
*/
define('ASSERTION_ERROR', 'Assertion Error');
/*_______________________________________________________________
*
* Runtime Error Messages
*/
define('RUNTIME_EXCEPTION', 'Runtime Exception');
define('SCRIPT_TIMEOUT_ERROR', 'Script Timeout');
/*_______________________________________________________________
*
* Dom-specific Error Messages
*/
define('INVALID_NODE_TYPE_VALUE', 'Invalid Node Type Value');
define('UNEXPECTED_NODE_TYPE', 'Unexpected Node Type');
<?php
// catch later as the event propagates upward
// throw new Exception( "Callee: " . ARITHMETIC_ERROR )