mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 20:03:05 +02:00
nf: TextImporter - add UnknownDelimiterException
Allows users to handle this exception separately
This commit is contained in:
parent
cab199935a
commit
dfc4e43bd8
@ -101,7 +101,10 @@ public class TextImporter extends NoteImporter {
|
||||
return notes;
|
||||
}
|
||||
|
||||
/** Number of fields. */
|
||||
/**
|
||||
* Number of fields.
|
||||
* @throws UnknownDelimiterException Could not determine delimiter (example: empty file)
|
||||
*/
|
||||
@Override
|
||||
public int fields() {
|
||||
open();
|
||||
@ -147,13 +150,13 @@ public class TextImporter extends NoteImporter {
|
||||
}
|
||||
|
||||
if (mDialect == null && mDelimiter == '\0') {
|
||||
throw new RuntimeException("unknownFormat");
|
||||
throw new UnknownDelimiterException();
|
||||
}
|
||||
}
|
||||
|
||||
@Contract(" -> fail")
|
||||
private void err() {
|
||||
throw new RuntimeException("unknownFormat");
|
||||
throw new UnknownDelimiterException();
|
||||
}
|
||||
|
||||
private void updateDelimiter() {
|
||||
@ -284,4 +287,10 @@ public class TextImporter extends NoteImporter {
|
||||
return Files.lines(Paths.get(mFile.getAbsolutePath()), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnknownDelimiterException extends RuntimeException {
|
||||
public UnknownDelimiterException() {
|
||||
super("unknownFormat");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user