Re: Exception handling?
Still working on digesting and attempting to implement all you gave me, but
have a couple of quick acknowledgements and questions:
****
If you want your exception code to clear this variable, you will have to do that
explicitly. Note that if this value is set AFTER the serialization call, because you are
handling the excepiton internally and not throwing it, there is zero hope that you will be
able to deal with this. Instead, you will have to add a handler for operations like
File::Save, you will have to put an exception handler in that code, you will have to have
your very own generic exception class (not CUserException), something like
CMySerializeException, of which CWrongFilieIDException is but one of the many
possible derived classes, and you will have to do a throw; instead of e->Delete()
so your exception is seen outside the serialize handler.
Oh ok, well that makes sense.
Never be afraid to create your own classes of exceptions when needed. Never
"hijack" some generic class. Make sure that every exception has useful information in
it so you can make a report (I included file name, line #, and offset-into-line in
CSyntaxException, and for things like CWrongSymbolException I had a placeholder
for the entity I expected, so I would do throw new CWrongSymbolException(file, line,
offset, IDS_EXPECTED_VARIABLE_NAME);
Oh, well I am beginning to see more of the concept which I totally misunderstood from
the docs I was reading. So I can derive exception classes not necessarily use ones already
written. I did find docs on the try and throw.
Ugh, do I declare this in global space or in each class it's needed ?
class CWrongFileIDException : public CException {
public:
DWORD GetFileID() { return fid; }
CWrongFileIDException(DWORD fileid) { fid = fileid; }
protected:
DWORD fid;
};
///That's all for now. Thanks !