On 11 June 2013 09:06, Neil Morgenstern <[email protected]> wrote:
> If there was one thing I really disliked about SOCI and had to change,
> it was getting silly meaningless context-less errors like bad_cast.
>
> I had to fix that to get it to try to work, e.g. convert different
> integer types, and then provide context if it still failed.

Neil,

I agree.

> Please consider making your exceptions meaningful, so if there is an
> error there, you know how to fix it.

The bad_cast is thrown by

    template<typename T>
    T get()
    {
        type_holder<T>* p = dynamic_cast<type_holder<T> *>(this);
        if (p)
        {
            return p->template value<T>();
        }
        else
        {
            throw std::bad_cast();
        }
    }

where little information on logical correspondance
between the source/target types, fields.

A simple solution, perhaps, would be to catch this exception in row::get(),
try to add some meaningful info from the row, and rethrow.

Suggestions on how you'd like to see it solved are welcome.

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to