Fix bug in exception handling for which(). Also standardize exceptions

to always be ValueError. Add the beginnings of to_dict()
This commit is contained in:
Jason Paryani
2013-09-03 00:25:32 -07:00
parent 26579d307d
commit c900690b96
5 changed files with 190 additions and 39 deletions

View File

@@ -10,4 +10,15 @@ T fixMaybe(::kj::Maybe<T> val) {
} else {
throw std::invalid_argument("member was null");
}
}
template<typename T>
const char * getEnumString(T val) {
auto maybe_val = val.which();
KJ_IF_MAYBE(new_val, maybe_val) {
return new_val->getProto().getName().cStr();;
} else {
return "";
}
}