Can someone please explain to me just exactly this try/catch is doing? It doesn't seem to make any sense to me. Thank you in advance.

    case '\r':
        if (Choice==(CancelIndex+1))return;                
        try{(*Action[Choice-1])();}
        catch(...){}
        system("cls");
        Choice = 1;
        break;

    case char(27):
        if ((CancelIndex+1)==ItemCount)return;
        try{(*Action[ItemCount-1])();}
        catch(...){}
        Choice = 1;
        break;

>Can someone please explain to me just exactly this try/catch is doing?
It's swallowing errors, basically ignoring them.

Is there really any reason to have in the code, or is this just a half-hearted attempt at trying to error detection?

Well, it has a legitimate purpose. The author probably didn't want exceptions to propagate beyond this scope. Without the catch, the unhandled exception would just go on until it hits the first catch or until it goes all the way out of the call stack, in which case the terminate function is called.

I'm not a fan of swallowing exceptions silently (at the very least it should be logged), but I wouldn't call it half-hearted either.

Thank you, that makes a lot of sense. I understand whats try to be acheived by using
this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.