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:
@@ -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 "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user