Version
main branch
Describe what's wrong
LanceScanner.scanBatches() catches IOException from the native openStream() method and wraps it as a bare RuntimeException (line 144). The same pattern exists in AsyncScanner at 4 locations (lines 140, 144, 151, 169).
Callers cannot distinguish IO errors (file not found, permission denied, corrupted data) from programming errors (NPE, etc.) without inspecting the cause chain.
The Arrow Scanner interface's scanBatches() does not declare throws IOException, so a checked exception is not feasible. A typed unchecked exception is preferable to bare RuntimeException.
Evidence of prior intent
FileReaderWriterTest.java already references LanceException in 3 separate fail messages (lines 122, 257, 263), e.g. fail("Expected LanceException to be thrown"). This indicates the community intended to use a custom exception class, but it was never introduced.
Note: those 3 test sites cover LanceFileReader, not LanceScanner. The file reader/writer path is out of scope for this fix and should be addressed in a follow-up.
How to reproduce
- Call
scanner.scanBatches() on a dataset path that doesn't exist or has permission issues
- The native layer throws
IOException
- The caller receives
RuntimeException with no way to catch IO-specific errors
Proposed fix
Introduce LanceException extends RuntimeException as a unified unchecked exception for Lance IO/operation errors:
| File |
Change |
java/src/main/java/org/lance/LanceException.java |
New: extends RuntimeException, constructors (String, Throwable) and (String) |
java/src/main/java/org/lance/ipc/LanceScanner.java:144 |
RuntimeException -> LanceException |
java/src/main/java/org/lance/ipc/AsyncScanner.java:140,144,151,169 |
RuntimeException -> LanceException |
Out of scope (follow-up): LanceFileReader / LanceFileWriter IO paths and the 3 FileReaderWriterTest catch blocks.
Version
main branch
Describe what's wrong
LanceScanner.scanBatches()catchesIOExceptionfrom the nativeopenStream()method and wraps it as a bareRuntimeException(line 144). The same pattern exists inAsyncScannerat 4 locations (lines 140, 144, 151, 169).Callers cannot distinguish IO errors (file not found, permission denied, corrupted data) from programming errors (NPE, etc.) without inspecting the cause chain.
The Arrow
Scannerinterface'sscanBatches()does not declarethrows IOException, so a checked exception is not feasible. A typed unchecked exception is preferable to bareRuntimeException.Evidence of prior intent
FileReaderWriterTest.javaalready referencesLanceExceptionin 3 separate fail messages (lines 122, 257, 263), e.g.fail("Expected LanceException to be thrown"). This indicates the community intended to use a custom exception class, but it was never introduced.Note: those 3 test sites cover
LanceFileReader, notLanceScanner. The file reader/writer path is out of scope for this fix and should be addressed in a follow-up.How to reproduce
scanner.scanBatches()on a dataset path that doesn't exist or has permission issuesIOExceptionRuntimeExceptionwith no way to catch IO-specific errorsProposed fix
Introduce
LanceException extends RuntimeExceptionas a unified unchecked exception for Lance IO/operation errors:java/src/main/java/org/lance/LanceException.javaextends RuntimeException, constructors(String, Throwable)and(String)java/src/main/java/org/lance/ipc/LanceScanner.java:144RuntimeException->LanceExceptionjava/src/main/java/org/lance/ipc/AsyncScanner.java:140,144,151,169RuntimeException->LanceExceptionOut of scope (follow-up):
LanceFileReader/LanceFileWriterIO paths and the 3FileReaderWriterTestcatch blocks.