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

Simon Willnauer commented on LUCENE-6217:
-----------------------------------------

I just wanna point out the consequences if you provide this as a getter rather 
than an exception:
{code}
  try {
    iw.addDocument(doc);
  } catch (TragicEventException ex) {
    // notify others that all bets are off
  } 
{code}

vs.

{code}
  try {
    iw.addDocument(doc);
  } catch (Throwable ex) {
    Throwable tragic = iw.getTragicEventException();
    if (tragic != null) {
      // notify others that all bets are off
    }
    throw ex; 
  } 
{code}

99% of the users won't catch this but would be happy to see it right away what 
happened. If you need to catch it ie. if you care to notify the dedicated 
exception is way nicer and more intuitive too. I'd vote for the exception and I 
don't see how this makes things more complicated, I am sure you have something 
in mind can you elaborate on that?

> IndexWriter should make it clear when tragedy strikes
> -----------------------------------------------------
>
>                 Key: LUCENE-6217
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6217
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>
> If you hit an exception at a "bad time" e.g. when writing files for a newly 
> flushed segment, IndexWriter declares it a tragedy and secretly closes itself 
> as a side effect of the exception.
> Subsequent operations will throw an ACE with the exception that caused the 
> tragedy as its cause.
> This requires messy code, if you want to know when this happened to you, 
> since the first exception doesn't make it clear that it was "tragic".
> I think we should make it easier to know when this happens?
> Maybe we could instead throw a new exception (IWClosedByTragedy or 
> something), or maybe we add a getter (.getTragicException) to IW?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to