GitList
Repositories
Help
Report an Issue
blackjack
Code
Commits
Branches
Tags
Search
Tree:
d7b0224
Branches
Tags
master
blackjack
Objects
Error.php
initial commit
Dev Ghai
commited
d7b0224
at 2014-04-17 16:55:27
Error.php
Blame
History
Raw
<?php /** * User: dev * Date: 3/11/14 * Time: 9:14 AM */ namespace Blackjack\Objects; require_once 'Config/Config.php'; use Blackjack\config\Config as Config; define('E_BJ_HAND_UNPLAYABLE', -19); define('E_BJ_UNKNOWN_HAND_STATE', -18); define('E_BJ_UNKNOWN_ENDGAME_STATE', -17); define('E_BJ_HAND_INVALID_SUM', -16); define('E_BJ_HAND_BAD_INDEX', -15); define('E_BJ_MOVE_UNKNOWN', -14); define('E_BJ_MOVE_NO_HAND_ID', -13); define('E_BJ_NO_ACTIVE_SESSION', -12); define('E_BJ_NO_NAME', -11); define('E_BJ_CANNOT_SPLIT', -10); define('E_BJ_HAND_LOCKED', -9); define('E_BJ_WRONG_CARD_INIT', -8); define('E_BJ_INSERT_FAILED', -7); define('E_BJ_EXECUTE_QUERY_FAILED', -6); define('E_BJ_PREPARE_QUERY_FAILED', -5); define('E_BJ_LOAD_RECV_PRI_KEY_FAILED', -4); define('E_BJ_LOAD_SEND_PUB_KEY_FAILED', -3); define('E_BJ_INVALID_FUNCTION_CALL', -2); define('E_BJ_DB_CONNECT_FAILED', -1); define('E_BJ_LOGIN_FAILED', 1); define('BJ_ERROR_CLASS_NAME', 'Error'); $allErrorDescriptions = array( E_BJ_INSERT_FAILED => 'There was error inserting data into the database.', E_BJ_EXECUTE_QUERY_FAILED => 'There was an error executing the query.', E_BJ_PREPARE_QUERY_FAILED => 'Mysqli had problems with preparing the statement to send to DB.', E_BJ_LOAD_RECV_PRI_KEY_FAILED => 'There was an error loading private key to decrypt data.', E_BJ_LOAD_SEND_PUB_KEY_FAILED => 'Loading public key to encrypt data before responding... failed. Anyway, what\'s up?', E_BJ_INVALID_FUNCTION_CALL => 'An invalid function call was made. Expected number of parameters were not delivered.', E_BJ_DB_CONNECT_FAILED => 'Could not connect to the database with the given credentials.', E_BJ_LOGIN_FAILED => 'ACCESS_DENIED', E_BJ_WRONG_CARD_INIT => 'A Card cannot be initialized with null for $suit or $value', E_BJ_HAND_LOCKED => 'The hand is locked probably because you doubled down or stood on a split hand. Cannot add more cards.', E_BJ_CANNOT_SPLIT => 'Cannot split hand.', E_BJ_NO_NAME => 'Player name not provided.', E_BJ_NO_ACTIVE_SESSION => 'An active session was not found. Please try restarting the game by resending just the name.', E_BJ_MOVE_NO_HAND_ID => 'Looks like the player wants to move but has not supplied id of the hand in which to make the move.', E_BJ_MOVE_UNKNOWN => 'Unknown move.', E_BJ_HAND_BAD_INDEX => 'An attempt was made to address an invalid hand.', E_BJ_HAND_INVALID_SUM => 'Sum of cards in hand is less than 17. Please Hit more.', E_BJ_UNKNOWN_ENDGAME_STATE => 'Unhandled end game state was encountered. Please file a bug with the developer with a description of all hands on the table.', E_BJ_UNKNOWN_HAND_STATE => 'An attempt was made to set hand to an unknown state. Please contact the developer. This is probably a programming error.', E_BJ_HAND_UNPLAYABLE => 'The hand is no longer playable as the match has ended with that hand.', ); class Error { public $errorCode; public $errorDescription; private $_config; function __construct($errorCode, $errorDescription = '') { global $allErrorDescriptions; $this->errorCode = $errorCode; if($errorDescription != '') $this->errorDescription = $errorDescription; else if(array_key_exists($errorCode, $allErrorDescriptions)) $this->errorDescription = $allErrorDescriptions[$errorCode]; $this->LogError($errorCode); } private function LogError($errorCode) { $this->_config = new Config(); if(!$this->_config->logError) { return; } } }