[ 
https://issues.apache.org/jira/browse/LUCENE-5405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13875710#comment-13875710
 ] 

Benson Margulies commented on LUCENE-5405:
------------------------------------------

I've been frustrated for years by the coincidence that IOException lacks 
constructors for 'cause', and the Lucene API is full of 'throws IOException'. 
However, I only just now noticed that Java fixed this in 1.6.

So, a weaker form of this would be a subclass of IOException that can carry a 
field name, and a place for TokenStream to hide a field name. Then something 
like the Solr error handler could instanceof to see if there's a field name to 
be had.

Given the other API changes to token stream component construction for 5.0, one 
might argue that adding a ctor arg isn't so bad.


> Exception strategy for analysis improved
> ----------------------------------------
>
>                 Key: LUCENE-5405
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5405
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Benson Margulies
>
> SOLR-5623 included some conversation about the dilemmas of exception 
> management and reporting in the analysis chain. Here is a 5.0 proposal:
> TokenStream.reset and TokenStream.incrementToken (and perhaps the rest) 
> should have a new, checked, exception in their signatures: call it 
> AnalysisError if you like. Unlike IOException, it will have a full set of 
> constructors, including the constructors that can wrap a 'cause'. Its 
> constructors will accept a field name.
> TokenStream will have a fieldName field, accepted in a constructor argument. 
> (OK, this might a bit authoritarian.)
> TokenStream will have:
>   protected void throwAnalysisException(String explanation, Throwable cause) {
>     throw new AnalysisException(fieldName, explanation, cause);
>   }
> Implementors of analysis will be thus encouraged to write things like:
>   try {
>     doSomething();
>   } catch (IOExceptionOrWhatever e) {
>     throwAnalysisException("Some Explanation", e);
>  }
> Then, situations like Solr can diagnose the field name.
> Note that no information is lost here, due to the use of exception wrapping.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to