When the account is not in the database or the account has insufficient privileges to access the database, an error needs to be reported.
A new error category is created to handle this with a separate message.
const NO_SESSION = 15;
const NO_SUPPORT = 16;
const POSTGRESQL_CONNECTION_FAILURE = 17;
- const POSTGRESQL_NO_CONNECTION = 18;
- const POSTGRESQL_NO_RESOURCE = 19;
- const POSTGRESQL_ERROR = 20;
- const SOCKET_FAILURE = 21;
- const ACCESS_DENIED = 22;
- const ACCESS_DENIED_UNAVAILABLE = 23;
- const ACCESS_DENIED_USER = 24;
- const ACCESS_DENIED_ADMINISTRATION = 25;
- const SERVER_ERROR = 26;
+ const POSTGRESQL_NO_ACCOUNT = 18;
+ const POSTGRESQL_NO_CONNECTION = 19;
+ const POSTGRESQL_NO_RESOURCE = 20;
+ const POSTGRESQL_ERROR = 21;
+ const SOCKET_FAILURE = 22;
+ const ACCESS_DENIED = 23;
+ const ACCESS_DENIED_UNAVAILABLE = 24;
+ const ACCESS_DENIED_USER = 25;
+ const ACCESS_DENIED_ADMINISTRATION = 26;
+ const SERVER_ERROR = 27;
/**
return c_base_return_string::s_new('Failed to connect to the database.');
}
}
+ elseif ($code === static::POSTGRESQL_NO_ACCOUNT) {
+ if ($arguments === TRUE) {
+ return c_base_return_string::s_new('Database access denied: the account :{database_account} does not exist or does not have the required access' . $function_name_string . '.');
+ }
+ else {
+ return c_base_return_string::s_new('Database access denied: the account does not exist or does not have the required access.');
+ }
+ }
elseif ($code === static::POSTGRESQL_NO_CONNECTION) {
if ($arguments === TRUE) {
return c_base_return_string::s_new('The database, :{database_name}, is not connected' . $function_name_string . '.');
return c_base_return_string::s_new('データベースに接続できませんでした。');
}
}
+ elseif ($code === static::POSTGRESQL_NO_ACCOUNT) {
+ if ($arguments === TRUE) {
+ return c_base_return_string::s_new('データベースアクセスが拒否されました:アカウント:{database_account}が存在しないか、必要なアクセス権' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ }
+ else {
+ return c_base_return_string::s_new('データベースアクセスが拒否されました:アカウントが存在しないか、必要なアクセス権がありません ');
+ }
+ }
elseif ($code === static::POSTGRESQL_NO_CONNECTION) {
if ($arguments === TRUE) {
return c_base_return_string::s_new('データベース :{database_name} は接続されていません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
$this->session->set_user_current($user_current);
}
else {
- // @todo: handle errors.
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{account_name}' => $last_error, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::POSTGRESQL_NO_ACCOUNT);
+ return c_base_return_error::s_false($error);
}
unset($user_current);
}
if (c_base_return::s_has_error($connected)) {
+ $this->session->set_error($connected->get_error());
unset($connected);
-
- $executed = $paths->get_handler_server_error($this->http, $this->database, $this->session, $this->settings);
+ $error_page = $paths->get_handler_server_error($this->http, $this->database, $this->session, $this->settings);
+ $executed = $error_page->do_execute($this->http, $this->database, $this->session, $this->settings);
+ unset($error_page);
}
else {
unset($connected);