Add proper Exceptions to class instead of false return on critical problems
This commit is contained in:
@@ -61,6 +61,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
* @param \CoreLibs\Logging\Logging $log Logging class
|
||||
* @param int $base_acl_level Set base acl level, if needed
|
||||
* @param int $acl_admin Flag if this is an admin ACL access level
|
||||
* @throws \RuntimeException Missing table array or table name entry
|
||||
*/
|
||||
public function __construct(
|
||||
array $db_config,
|
||||
@@ -83,6 +84,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
// error abort if no table array or no table name
|
||||
if (empty($table_array) || empty($table_name)) {
|
||||
$this->__dbError(1999, false, 'MAJOR ERROR: Core settings missing');
|
||||
throw new \RuntimeException('MAJOR ERROR: Core settings missing', 1999);
|
||||
}
|
||||
|
||||
// set primary key for given table_array
|
||||
|
||||
@@ -340,6 +340,7 @@ class IO
|
||||
// 4: convert numeric/floatN to float (CONVERT_NUMERIC)
|
||||
// 8: convert bytea to string data (CONVERT_BYTEA)
|
||||
/** @var int type settings as bit mask, 0 for off, anything >2 will aways set 1 too */
|
||||
/** @phan-suppress-next-line PhanInvalidConstantExpression, PhanUndeclaredClassConstant */
|
||||
private int $convert_type = Convert::off->value;
|
||||
// FOR BELOW: (This should be private and only readable through some method)
|
||||
// cursor array for cached readings
|
||||
@@ -413,6 +414,7 @@ class IO
|
||||
* phpcs:ignore
|
||||
* @param array{db_name:string,db_user:string,db_pass:string,db_host:string,db_port:int,db_schema:string,db_encoding:string,db_type:string,db_ssl:string,db_convert_type?:string[]} $db_config DB configuration array
|
||||
* @param \CoreLibs\Logging\Logging $log Logging class
|
||||
* @throws \RuntimeException If no DB connection can be established on launch
|
||||
*/
|
||||
public function __construct(
|
||||
array $db_config,
|
||||
@@ -491,6 +493,7 @@ class IO
|
||||
if (!$this->__connectToDB()) {
|
||||
$this->__dbError(16);
|
||||
$this->db_connection_closed = true;
|
||||
throw new \RuntimeException('INIT: No DB Handler found / connect or reconnect failed', 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -973,9 +976,9 @@ class IO
|
||||
/**
|
||||
* write an error
|
||||
*
|
||||
* @param integer $error_id Any Error ID, used in debug message string
|
||||
* @param integer $error_id Any Error ID, used in debug message string
|
||||
* @param \PgSql\Result|false $cursor Optional cursor, passed on to preprocessor
|
||||
* @param string $msg optional message added to debug
|
||||
* @param string $msg optional message added to debug
|
||||
* @return void
|
||||
*/
|
||||
protected function __dbError(
|
||||
|
||||
Reference in New Issue
Block a user