Re: [Lapackpp-devel] error handling
Status: Beta
Brought to you by:
cstim
From: Christian S. <sti...@tu...> - 2006-11-24 15:39:36
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dominik Wagenfuehr schrieb: >> As for the output - I think this is usually redirected to > ~/.xsession-errors, > > What's the Windows pendant? I don't know. I don't know windows that much. >> and at the next failed assert() you will get a thrown LaException >> instead of a failed assert. Is this what you wanted? > > I will take a look at it. Maybe I should describe how I do my error > handling in libraries. :) > > I have a special static class called MyMessage with different enums for > each error that can occur. If in a function an error occures I do > > MyMessage::Set(ERROR_DEFINEMENT, "Class::FunctionA"); > return(true); > > The functionB that called this failed functionA sees in the return > argument that something went wrong. It now can decide if to goes one or do > > MyMessage::Append("Class::FunctionB"); > return(true); > > In this way I will create an error stack in the static class. At top > level (that means in the GUI in most cases) I finally now can get the > error and the stack > > MyMessage::GetMessage() and MyMessage::GetStack() > > and give the user a correct output. This means in a console application > a console output, in a GUI-app maybe a little window message. I think you can do this very well by using the new modifications in laexcp.h, and then you enclose each lapackpp call by try{ // ... } catch (LaException &e) { MyMessage::Set(BLA, e.what() ); } and continue accordingly. > Further sometimes the user can decide what he wants to do now. In most > cases he should copy the message, save all his data (as far as this is > possible) and send a bug report to me. But if the GUI just crashes > (maybe after an hour of computing something) without any output the user > may become a little impatient. ;) > > I know that this is complicated especially implementing the return > values of all functions (it took me a dew days to change my code.) And > now I could not return something else but do most things by call by > reference. The advantage of it is that my library (or better the program > of a user with my library) never crashes unless the programmer does not > catch my error output and just go on as nothing happens. > > You can read something about this indirect error control in > Piegl/Tiller: "The NURBS Book", p. 607, chapter "B-spline Programming > Concept / Error control". There my be better programming books for it > but this one explained it clear enough. :) This kind of error handling seems a bit twisted to me, and at least the "one static class" concept isn't any different than the standard libc approach with one static variable errno. Whatever. I guess it will work anyway. Have fun, Christian -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQCVAwUBRWcSK2XAi+BfhivFAQIUsAP+Phm/2i46JL2y66nkCvCs0U/pmEHHF7KA 2733vCd20WC8KReXdret1dbE8eWCO3tf4D3hpJ3hEJ9edFGPtZEgDrPuRynt8cXZ oYSDBRok/fHCZFyje7TU5goWRywhOqWwdellG/zQW4N+UTv4NLBlxAgUh/xeMXbz i10y18RRIuw= =zNOb -----END PGP SIGNATURE----- |