Symfony – try/catch on array key

In my Symfony project I want to use try{} / catch{} on if array_key_exsists() .

My code is not finished here:

$response = $this->request('POST', $endpoint, $options, false);
    if (array_key_exists('error', $response)) {
        try {
            
        } catch (Exception $e) {
             $this->exception($response['error'] . $e->getMessage() );
        }
    }

I have created my custom exception which is called $this->exception() . I want to use it if the error key exists in a response. It work without try / catch but don’t know how to trun in other way around to make it work in this example..

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *