bugfixes + moving customException to canary

This commit is contained in:
Joey Kimsey
2024-08-20 06:25:36 -04:00
parent ef4818356c
commit 8cd7a6ebbc
4 changed files with 20 additions and 103 deletions

View File

@ -1,78 +0,0 @@
<?php
/**
* classes/custom_exception.php
*
* This class is used exclusively when throwing predefined exceptions.
* It will intercept framework thrown exceptions and deal with them however
* you choose; in most cases by logging them and taking appropriate responses
* such as redirecting to error pages.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Classes;
use Exception;
use TheTempusProject\Hermes\Functions\Redirect;
use TheTempusProject\Canary\Bin\Canary as Debug;
class CustomException extends Exception {
private $originFunction = null;
private $exceptionName = null;
private $originClass = null;
private $data = null;
/**
* This function allows the application to deal with errors
* in a dynamic way by letting you customize the response
*
* @param string $type - The type of the exception being called/thrown.
* @param string $data - Any additional data being passed with the exception.
*
* @example - throw new CustomException('model'); - Calls the model-missing exception
*/
public function __construct( $type, $data = null ) {
$this->originFunction = debug_backtrace()[1]['function'];
$this->originClass = debug_backtrace()[1]['class'];
$this->exceptionName = $type;
$this->data = $data;
switch ( $type ) {
case 'model':
Debug::error( 'Model not found: ' . $data );
break;
case 'dbConnection':
Debug::error( 'Error Connecting to the database: ' . $data );
break;
case 'DB':
Debug::error( 'Unspecified database error: ' . $data );
break;
case 'view':
Debug::error( 'View not found: ' . $data );
break;
case 'controller':
Debug::error( 'Controller not found: ' . $data );
Redirect::to( 404 );
break;
case 'defaultController':
Debug::error( 'DEFAULT Controller not found: ' . $data );
Redirect::to( 404 );
break;
case 'method':
Debug::error( 'Method not found: ' . $data );
Redirect::to( 404 );
break;
case 'simpleView':
Debug::error( 'View not found: ' . $data );
break;
case 'defaultMethod':
Debug::error( 'DEFAULT Method not found: ' . $data );
Redirect::to( 404 );
break;
default:
Debug::error( 'Default exception: ' . $data );
break;
}
}
}

View File

@ -16,6 +16,7 @@ namespace TheTempusProject\Bedrock\Classes;
use PDO;
use PDOException;
use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Canary\Classes\CustomException;
class Database {
public static $instance = null;

View File

@ -18,6 +18,7 @@ use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Houdini\Classes\Views;
class Pagination extends Template {
//The settings that will not change