相关文章推荐
I get this error from time to time, when working with my project, only
to be left scratching my head wondering which field in my model in my
pool of many models actually caused my error.

Where would one go to enhance this message a bit to perhaps include
information about which typeid() were being cast from/to that might help
narrow down the offender?
[2016-May-18 07:08:45.155147] 11116 [/ NbFHa6mqNw7gIAb0] [error] "Wt: error during event handling: boost::bad_any_cast: failed conversion using boost::any_cast"
[2016-May-18 07:08:45.155272] 11116 [/ NbFHa6mqNw7gIAb0] [error] "Wt: fatal error: boost::bad_any_cast: failed conversion using boost::any_cast"
[2016-May-18 07:08:45.155308] 11116 - [info] "WebController: Removing session NbFHa6mqNw7gIAb0"
--
~mark
~w:http://www.lorimarksolutions.com
Hey Mark,

It's unfortunate that the cast itself does not reference the relevant
typeid information (perhaps for some advanced good reason), ASFAIK.
Thus, from the log files it's impossible to tell.

You could however wrap all boost::cast<...>() calls into a helper function
that throws an exception carrying the relevant information?

Something like (untested):

template <typename T>
T my_any_cast(const boost::any& a) {
try {
return boost::any_cast<T>(a);
} catch (boost::bad_any_cast&) {
throw std::runtime_error("Bad any_cast: contains " + a.type().name()
+ ", casting to " + typeid(T).name());
}
}

Regards,
Koen
Post by Mark at Lorimark
I get this error from time to time, when working with my project, only
to be left scratching my head wondering which field in my model in my
pool of many models actually caused my error.
Where would one go to enhance this message a bit to perhaps include
information about which typeid() were being cast from/to that might help
narrow down the offender?
error during event handling: boost::bad_any_cast: failed conversion using
boost::any_cast"
fatal error: boost::bad_any_cast: failed conversion using boost::any_cast"
[2016-May-18 07:08:45.155308] 11116 - [info] "WebController: Removing
session NbFHa6mqNw7gIAb0"
--
~mark
~w:http://www.lorimarksolutions.com
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data
untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
 
推荐文章