We don't autogenerate the C++ Status class, so I think a minimally viable Java implementation could be hand-written too, manually updated when a new code is added. It's annoying but it's not the end of the world; error codes are rarely added.
On Fri, Mar 25, 2016 at 11:54 AM, Mike Percy <[email protected]> wrote: > So I am looking at the way the error codes are propagated in the Java > client and we don't currently have something approximating what is in the > C++ code for the Status object. > > C++ Status class: > https://github.com/apache/incubator-kudu/blob/master/src/kudu/util/status.h > Java RowError class: > > https://github.com/apache/incubator-kudu/blob/master/java/kudu-client/src/main/java/org/kududb/client/RowError.java > > This means that people who want to do specific error handling for things > like rows that are always present need to write something like this: > > List<OperationResponse> responses = session.flush(); > for (OperationResponse r : responses) { > if (r.getStatus().equals("ALREADY_PRESENT")) { > // Handle already present case... > } else if (...) { > // etc. > } > } > > Hard-coding string values is unfortunate and error prone so I think we can > do better. It turns out that the values are already encoded in a protobuf @ > > https://github.com/apache/incubator-kudu/blob/master/src/kudu/common/wire_protocol.proto > so possibly the best approach would be to codegen a Java Status class from > the AppStatusPB somehow. Thoughts? > > -- > Mike Percy > Software Engineer, Cloudera >
