Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Dec 2008
    Posts
    5

    Default Error Handling with WHM when create account

    Hello everyone!

    I have a question about this integration: http://cpanel.net/remoteaccess-php.html

    When I run the "createacct" function everything works out fine however, if a domain already exists on my server I get the following error:

    Sorry, a DNS entry for domain.com already exists, please delete it first (from all servers in the dns cluster)

    That's not the best error message to display to clients... I tried doing something like this but it didn't work, any suggestions?

    PHP Code:
    if ($test->errors[0] == "Sorry, a DNS entry for $domain already exists, please delete it first (from all servers in the dns cluster)") {
        
    $test->errors[0] = "something else";
        print 
    $test->errors[0];

    When I print $test->errors[0] and "Sorry, a DNS entry for $domain already exists, please delete it first (from all servers in the dns cluster)" they are the same but it doesn't actually get inside.

    Here is how the messages are handled now in the class:

    PHP Code:
    if($xml->result->status==1)
    {
         
    $result['status']=$xml->result->status;
         
    $result['statusmsg']=$xml->result->statusmsg;
         
    $result['ip']=$xml->result->options->ip;
         
    $result['nameserver']=$xml->result->options->nameserver;
         
    $result['nameserver2']=$xml->result->options->nameserver2;
         
    $result['nameserver3']=$xml->result->options->nameserver3;
         
    $result['nameserver4']=$xml->result->options->nameserver4;
         
    $result['package']=$xml->result->options->package;
         
    $result['rawout']=$xml->result->rawout;
         return 
    $result;
    }
    else
    {
         
    $this->errors[]=$xml->result->statusmsg;
         return 
    false;

    It would be nice if there was something like this:
    PHP Code:
    $this->errors[]=$xml->result->statuscode
    statuscode would contain a numeric value so I can do a switch statement on that value to display what I would like to display.

    I hope that helps.

    Let me know if you need more info from me.

    Thanks,

    Luke

  2. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Are you trimming the newline that occurs both before and after that phrase in the raw XML output? If not, that would explain why your exact comparison (==) is not working as you intend.

  3. #3
    Member
    Join Date
    Dec 2008
    Posts
    5

    Default

    Quote Originally Posted by cPanelDavidG View Post
    Are you trimming the newline that occurs both before and after that phrase in the raw XML output? If not, that would explain why your exact comparison (==) is not working as you intend.
    Wow!! I can't be believe I didn't think of that... it works!

    Thanks a lot. Any thoughts on the error handling statuscode? Unnecessary or good idea?

  4. #4
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by lhoezee View Post
    Wow!! I can't be believe I didn't think of that... it works!

    Thanks a lot. Any thoughts on the error handling statuscode? Unnecessary or good idea?
    Statuscode tends to be the return value from the Perl scripts these APIs eventually call. In Perl, a return value of 1 indicates success, 0 is typically used to indicate non-success. Therefore, the statuscode will usually be either 1 or 0, 1 indicating success.

    If I was coding an application that used the APIs, I'd be looking at the statuscode solely to determine if my function call was successful. If it wasn't 1 (1 indicating success), then I'd go into my error handling routines.
    Last edited by cPanelDavidG; 12-22-2008 at 04:51 PM. Reason: Clarification that 1 = successful.

  5. #5
    Member
    Join Date
    Dec 2008
    Posts
    5

    Default

    Quote Originally Posted by cPanelDavidG View Post
    Statuscode tends to be the return value from the Perl scripts these APIs eventually call. In Perl, a return value of 1 indicates success, 0 is typically used to indicate non-success. Therefore, the statuscode will usually be either 1 or 0, 1 indicating success.

    If I was coding an application that used the APIs, I'd be looking at the statuscode solely to determine if my function call was successful. If it wasn't 1 (1 indicating success), then I'd go into my error handling routines.
    Thanks for the time. That helps a lot.

    Have a good week!

    Luke

Similar Threads & Tags
Similar threads

  1. Create Account Error >
    By mesas in forum Enkompass Discussions
    Replies: 2
    Last Post: 10-22-2010, 02:25 PM
  2. remote access, php error handling status?
    By adamint in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 04-15-2006, 02:34 PM
  3. error (Create a New Account)
    By maad in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 04-29-2004, 04:50 PM
  4. WHM - php error handling of remote access functions
    By jimcarter in forum cPanel and WHM Discussions
    Replies: 9
    Last Post: 09-24-2002, 01:18 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube