R
R
ragnar_ok2019-08-29 16:40:46
1C-Bitrix
ragnar_ok, 2019-08-29 16:40:46

How to get status: error (bitrix ajax d7)?

I am using BX.ajax.runComponentAction.
How to generate an error inside the *Action method?
I am trying to throw an Exception but the status is still success. Why?

public function sendMessageAction(): string
{
    $i = 0;
    try {
        if ($i === 0) {
            throw new Exception('Ошибка');
        }
    } catch (Exception $e) {
        return (string) $e->getMessage(); // status: success
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2019-08-29
@ragnar_ok

public function sendMessageAction(): string
{
    $i = 0;

    if ($i === 0) {
        throw new Exception('Ошибка');
    }
    
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question