std::string formatException(Box* b) { const std::string* name = getTypeName(b); BoxedString* r = strOrNull(b); if (!r) return *name; assert(r->cls == str_cls); const std::string* msg = &r->s; if (msg->size()) return *name + ": " + *msg; return *name; }
std::string formatException(Box* b) { const std::string* name = getTypeName(b); Box* attr = b->getattr("message"); if (attr == nullptr) return *name; BoxedString* r = strOrNull(attr); if (!r) return *name; assert(r->cls == str_cls); const std::string* msg = &r->s; return *name + ": " + *msg; }