avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: explicit schema verification?
Date Wed, 07 Sep 2011 21:19:01 GMT
On 09/07/2011 01:40 PM, James Baldassari wrote:
> We could perhaps have a new exception type that would be a subclass of
> AvroRuntimeException and would be thrown specifically when a
> non-nullable field is undefined, for example NonNullableFieldException. 

I see three choices, none perfect:

 1. Use a subclass of NullPointerException in both builder and
non-builder code.  This provides consistency and back-compatibility, but
does not permit folks to catch all Avro runtime exceptions with a single
clause.

 2. Use a subclass of AvroRuntimeException in both builder and
non-builder code.  This would not be backwards compatible, but would
provide consistency and permits folks to catch all Avro runtime
exceptions with a single clause.

 3. Throw one exception from the builder code and a different exception
from the non-builder code.

My instinct is to go with (1).  Folks can always add a second catch
clause if they wish to distinguish Avro runtime exceptions from other
runtime exceptions.  I'm not sure that distinction is always meaningful
anyway, since Avro might already throw other runtime exceptions that are
not subclasses of AvroRuntimeException.

Doug

Mime
View raw message