Skip to content

Commit

Permalink
Updatre WHMv1 create() add additional debug data to error results
Browse files Browse the repository at this point in the history
  • Loading branch information
uphlewis committed Dec 4, 2024
1 parent 889a551 commit 53ef893
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions src/WHMv1/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ public function create(CreateParams $params): AccountInfo
if ($createException instanceof ProvisionFunctionError) {
throw $createException->withData(array_merge($createException->getData(), [
'get_info_error_after_timeout' => $getInfoException->getMessage(),
'params' => [
'username' => $username,
'domain' => $domain,
'password' => $password,
],
]));
}
}
Expand All @@ -224,38 +229,49 @@ public function create(CreateParams $params): AccountInfo
*/
protected function finishCreate(CreateParams $params, string $domain, string $username, string $password): AccountInfo
{
$info = $this->getAccountInfo($username)
->setMessage('Account created');
try {
$info = $this->getAccountInfo($username)
->setMessage('Account created');

if ($info->reseller && $params->reseller_options) {
try {
$this->changeResellerOptions($username, $params->reseller_options);
} catch (\Throwable $e) {
// clean-up
$this->deleteAccount($username);
if ($info->reseller && $params->reseller_options) {
try {
$this->changeResellerOptions($username, $params->reseller_options);
} catch (\Throwable $e) {
// clean-up
$this->deleteAccount($username);

throw $e;
throw $e;
}
}
}

if ($this->configuration->softaculous_install) {
try {
$softaculous = $this->getSoftaculous($username, $password);
if ($this->configuration->softaculous_install) {
try {
$softaculous = $this->getSoftaculous($username, $password);

if ($this->configuration->softaculous_install === 'wordpress') {
$installation = $softaculous->installWordpress($domain, $params->email);
}
if ($this->configuration->softaculous_install === 'wordpress') {
$installation = $softaculous->installWordpress($domain, $params->email);
}

$info->setSoftware($installation ?? null);
} catch (\Throwable $e) {
// clean-up
$this->deleteAccount($username);
$info->setSoftware($installation ?? null);
} catch (\Throwable $e) {
// clean-up
$this->deleteAccount($username);

throw $e;
throw $e;
}
}
}

return $info;
return $info;
} catch (ProvisionFunctionError $e) {
$errorData = $e->getData();
$errorData['params'] = [
'username' => $username,
'domain' => $domain,
'password' => $password,
];

throw $e->withData($errorData);
}
}

/**
Expand Down

0 comments on commit 53ef893

Please sign in to comment.