|
|
|
TRY CATCH
|
|||
|---|---|---|---|
|
#18+
Всем привет. Пытаюсь разобраться с исключениями в builder C++. написал простенький тест: void __fastcall TForm1::Button1Click(TObject *Sender) { try { double d = sqrt(-4); Edit1->Text = FloatToStr(d); } catch(...) { Application->MessageBoxA("Error","Error",MB_OK); } } ошибка вылетает Билдеровская все время а моя нет, я в настройках (Tools\Debugger Options) отключил все что только можно было. не помогло. Пробовал просто скомпиленный EXE файл запустить все равно такая же хрень. Может кто знает что делать ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.08.2007, 18:51 |
|
||
|
TRY CATCH
|
|||
|---|---|---|---|
|
#18+
может это не есть исключение ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.08.2007, 19:00 |
|
||
|
TRY CATCH
|
|||
|---|---|---|---|
|
#18+
Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. так работает ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.08.2007, 19:03 |
|
||
|
TRY CATCH
|
|||
|---|---|---|---|
|
#18+
sqrt - неудачная функция для примера ловли исключений... Дело в том, что Борландовская реализация библиотеки math в случае ошибок выплёвывает месажбокс с информацией об ошибке, если не задан обработчик _matherr/_matherrl. Borland C++ Builder Help ............ Prototype double sqrt(double x); long double sqrtl(long double x); .................. Error handling for these functions can be modified through the functions _matherr and _matherrl. ну и Borland C++ Builder Help Header File math.h Category Diagnostic Routines, Math Routines Prototype int _matherr(struct _exception *e); int _matherrl(struct _exceptionl *e); Description User-modifiable math error handler. _matherr is called when an error is generated by the math library. _matherrl is the long double version; it is called when an error is generated by the long double math functions. _matherr and _matherrl each serve as a user hook (a function that can be customized by the user) that you can replace by writing your own math error-handling routine. _matherr and _matherrl are useful for information on trapping domain and range errors caused by the math functions. They do not trap floating-point exceptions, such as division by zero. See signal for information on trapping such errors. You can define your own _matherr or _matherrl routine to be a custom error handler (such as one that catches and resolves certain types of errors); this customized function overrides the default version in the C library. The customized _matherr or _matherrl should return 0 if it fails to resolve the error, or nonzero if the error is resolved. When _matherr or _matherrl return nonzero, no error message is printed and the global variable errno is not changed. ...................... Ну и поскольку "They do not trap floating-point exceptions, such as division by zero.", пример с делением на 0 работает. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.08.2007, 22:31 |
|
||
|
|

start [/forum/topic.php?fid=57&msg=34708886&tid=2028410]: |
0ms |
get settings: |
10ms |
get forum list: |
20ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
196ms |
get topic data: |
11ms |
get forum data: |
2ms |
get page messages: |
51ms |
get tp. blocked users: |
2ms |
| others: | 231ms |
| total: | 531ms |

| 0 / 0 |
