Skip to content

Commit

Permalink
Fix PDF parser swallows error message about duplicate securities (#4383)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Ott <[email protected]>
  • Loading branch information
buchen and Nirus2000 authored Dec 3, 2024
1 parent e773fdc commit d5bbd9c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package name.abuchen.portfolio.datatransfer;

public class DuplicateSecurityException extends IllegalArgumentException
{
private static final long serialVersionUID = 1L;

public DuplicateSecurityException(String s)
{
super(s);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Security lookup(String isin, String tickerSymbol, String wkn, String name
// message is only returned to the user if the other attributes also did
// not match
if (idOfAttributeWithDuplicateSecurities >= 0)
throw new IllegalArgumentException(MessageFormat.format(MESSAGES.get(idOfAttributeWithDuplicateSecurities),
throw new DuplicateSecurityException(MessageFormat.format(MESSAGES.get(idOfAttributeWithDuplicateSecurities),
attributes.get(idOfAttributeWithDuplicateSecurities)));

// second: check the name. But: even if the name matches, we also must
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import name.abuchen.portfolio.Messages;
import name.abuchen.portfolio.datatransfer.DocumentContext;
import name.abuchen.portfolio.datatransfer.DuplicateSecurityException;
import name.abuchen.portfolio.datatransfer.Extractor.Item;
import name.abuchen.portfolio.datatransfer.ImportAction;
import name.abuchen.portfolio.datatransfer.ImportAction.Context;
Expand Down Expand Up @@ -366,6 +367,10 @@ public void parse(String filename, DocumentContext documentContext, String[] lin
// if parsing was successful, then return
return;
}
catch (DuplicateSecurityException e)
{
throw e;
}
catch (IllegalArgumentException ignore)
{
// try next sub-section
Expand Down

0 comments on commit d5bbd9c

Please sign in to comment.