XF 2.2 How to throw exception in setup process

FoxSecrets

Active member
I need to throw exception in setup but the class is already extended by AbstractSetup and the exception comes from AbstractController.
Is there an easy way to get the exception and throw a message? Or can I extends two classes at the same time ?

Code:
public function uninstallStep1()
    {
            $data = \XF::finder('My\Addon:Class')->fetchOne();


            if ($data['column']) {
                throw $this->exception(
                    $this->error(\XF::phrase('not_valid'))
                );
            }
    }
 
If I try to return I got the error message: "Must return a StepResult object" .

How is a StepResult object?
 
I would advise against throwing exceptions during uninstallation. It will leave the add-on in an inconsistent state and is a bad experience for end-users. You should handle whatever error condition you're anticipating gracefully.
 
Back
Top Bottom