In some cases it can be useful to show the registrars epp/api error to the client directly in the client area. In our case the client is not allowed to change the company name for a .no domain name, but the error shown for the client does not make any sense.
function registrarShowErrorMessage($vars){ // This global is set in registrar.php and utilized because WHMCS Refuses to show the errors returned by the module functions $errormsg = $GLOBALS['registrar_error']; unset($GLOBALS['registrar_error']); return array( 'error' => $errormsg, ); }
Note the hook needs to be
Websavers
commented
3 days ago
Totally agree. The errors are hard-coded in the language files like this:
$_LANG['domainDetails']['error']['deleteNs'] = "An issue was encountered while deleting the private nameserver. Please contact support."; $_LANG['domainDetails']['error']['getContact'] = "An issue was encountered while retrieving the domain contact details. Please contact support."; $_LANG['domainDetails']['error']['getDns'] = "An issue was encountered while retrieving the DNS records. Please contact support."; $_LANG['domainDetails']['error']['getEmailFwd'] = "An issue was encountered while retrieving the email forwarders. Please contact support."; $_LANG['domainDetails']['error']['getNs'] = "An issue was encountered while retrieving the domain nameservers. Please contact support."; $_LANG['domainDetails']['error']['modifyNs'] = "An issue was encountered while modifying the private nameserver. Please contact support."; $_LANG['domainDetails']['error']['registerNs'] = "An issue was encountered while registering the private nameserver. Please contact support."; $_LANG['domainDetails']['error']['releaseDomain'] = "An issue was encountered while releasing the domain. Please verify your input value and try again."; $_LANG['domainDetails']['error']['resendNotification'] = "An issue was encountered while resending the notification email. Please contact support."; $_LANG['domainDetails']['error']['saveContact'] = "An issue was encountered while updating the domain contact details. Please contact support."; $_LANG['domainDetails']['error']['saveDns'] = "An issue was encountered while updating the DNS records. Please contact support."; $_LANG['domainDetails']['error']['saveEmailFwd'] = "An issue was encountered while updating the email forwarders. Please contact support."; $_LANG['domainDetails']['error']['saveNs'] = "An issue was encountered while updating the domain nameservers. Please contact support."; $_LANG['domainDetails']['error']['saveRegLock'] = "An issue was encountered while updating the domain lock status. Please contact support.";
Yet that error data goes nowhere because WHMCS chooses not to show it. Why expect good error handling practice from your developers, then fail to follow through on it with your own code?
2 Comments
Login to post a comment.
if (isset($values['error'])) $GLOBALS['registrar_error'] = $values['error']; //use this in hooks.php
Then in the registrar module's hooks.php:
add_hook('ClientAreaPageDomainAddons', 1, 'registrarShowErrorMessage');
add_hook('ClientAreaPageDomainContacts', 1, 'registrarShowErrorMessage');
add_hook('ClientAreaPageDomainDNSManagement', 1, 'registrarShowErrorMessage');
add_hook('ClientAreaPageDomainEmailForwarding', 1, 'registrarShowErrorMessage');
add_hook('clientareapagedomainregisternameservers', 1, 'registrarShowErrorMessage');
function registrarShowErrorMessage($vars){
// This global is set in registrar.php and utilized because WHMCS Refuses to show the errors returned by the module functions
$errormsg = $GLOBALS['registrar_error'];
unset($GLOBALS['registrar_error']);
return array(
'error' => $errormsg,
);
}
Note the hook needs to be
$_LANG['domainDetails']['error']['deleteNs'] = "An issue was encountered while deleting the private nameserver. Please contact support.";
$_LANG['domainDetails']['error']['getContact'] = "An issue was encountered while retrieving the domain contact details. Please contact support.";
$_LANG['domainDetails']['error']['getDns'] = "An issue was encountered while retrieving the DNS records. Please contact support.";
$_LANG['domainDetails']['error']['getEmailFwd'] = "An issue was encountered while retrieving the email forwarders. Please contact support.";
$_LANG['domainDetails']['error']['getNs'] = "An issue was encountered while retrieving the domain nameservers. Please contact support.";
$_LANG['domainDetails']['error']['modifyNs'] = "An issue was encountered while modifying the private nameserver. Please contact support.";
$_LANG['domainDetails']['error']['registerNs'] = "An issue was encountered while registering the private nameserver. Please contact support.";
$_LANG['domainDetails']['error']['releaseDomain'] = "An issue was encountered while releasing the domain. Please verify your input value and try again.";
$_LANG['domainDetails']['error']['resendNotification'] = "An issue was encountered while resending the notification email. Please contact support.";
$_LANG['domainDetails']['error']['saveContact'] = "An issue was encountered while updating the domain contact details. Please contact support.";
$_LANG['domainDetails']['error']['saveDns'] = "An issue was encountered while updating the DNS records. Please contact support.";
$_LANG['domainDetails']['error']['saveEmailFwd'] = "An issue was encountered while updating the email forwarders. Please contact support.";
$_LANG['domainDetails']['error']['saveNs'] = "An issue was encountered while updating the domain nameservers. Please contact support.";
$_LANG['domainDetails']['error']['saveRegLock'] = "An issue was encountered while updating the domain lock status. Please contact support.";
This is all despite the fact that the sample registrar module shows that devs should be returning errors in each function: https://github.com/WHMCS/sample-registrar-module/blob/master/modules/registrars/registrarmodule/registrarmodule.php
Yet that error data goes nowhere because WHMCS chooses not to show it. Why expect good error handling practice from your developers, then fail to follow through on it with your own code?