169 похожих чатов

How can i do multiple statements when an error occurs?

because after "except on do" construct I can't put begin and end; and it only allows for 1 statement to be executed.
try
SList.LoadFromFile(Filename);
except on E:EFOpenError do
// doing other things here maybe 🤔
Halt(1);
end;

13 ответов

61 просмотр

Except on e:efopenerror do begin ... end; on e:exception do begin ... end; end;

except-end is equivalent to begin-end, so simply: try SList.LoadFromFile(Filename); except functionA(); functionB(arg1, arg2); if(something) then begin bla bla blah end else begin blah blah end; Halt(1); end;

that's what the except section is for ;)

Варёный Котелок
that's what the except section is for ;)

it is designed to handle errors in the first place. And redundant and large code inside the exception can throw a new exception that will no longer be caught.

Варёный Котелок
some times yes, other times no

"And redundant and large code inside the exception can throw a new exception that will no longer be caught."

Горячий Инжир
"And redundant and large code inside the exception...

this is interesting point. I do use nested try-except often, in order to suppress exception messages.

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Мелодичный Сырник
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Фетровый Лингвист
2
30500 за редактор? )
Замшевый Алхимик
47
а через ESC-код ?
Виноградная Притча
29
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
Сентиментальная Вершина
18
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
Отзывчивая Шестерёнка
14
Добрый день! Скажите пожалуйста, а какие программы вы бы рекомендовали написать для того, чтобы научиться управлять памятью? Можно написать динамический массив, можно связный ...
Клюквенный Як
7
Недавно Google Project Zero нашёл багу в SQLite с помощью LLM, о чём достаточно было шумно в определённых интернетах, которые сопровождались рассказами, что скоро всех "ибешни...
Волшебный Ленивец
5
Ребят в СИ можно реализовать ООП?
Стеклянный Граммофон
33
https://github.com/erlang/otp/blob/OTP-27.1/lib/kernel/src/logger_h_common.erl#L174 https://github.com/erlang/otp/blob/OTP-27.1/lib/kernel/src/logger_olp.erl#L76 15 лет назад...
Укропная Путница
20
Карта сайта