Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PDF parser swallows error message about duplicate securities #4383

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading