public isolated function getBooks() returns Book[]|sql:Error {
stream<Book, sql:Error?> resultStream = dbClient->query(getQuery());
if resultStream is stream<Book> {
return from Book book in resultStream select book;
}
return error("Error fetching books");
}
The is check should never evaluate to true, should it? But it evaluates to true.
Then if there's an error (e.g., mismatched column/record names), crashes
[2024-11-13 11:08:24,871] SEVERE {b7a.log.crash} - class io.ballerina.runtime.internal.values.ErrorValue cannot be cast to class io.ballerina.runtime.internal.values.ArrayValue (io.ballerina.runtime.internal.values.ErrorValue and io.ballerina.runtime.internal.values.ArrayValue are in unnamed module of loader 'app')
java.lang.ClassCastException: class io.ballerina.runtime.internal.values.ErrorValue cannot be cast to class io.ballerina.runtime.internal.values.ArrayValue (io.ballerina.runtime.internal.values.ErrorValue and io.ballerina.runtime.internal.values.ArrayValue are in unnamed module of loader 'app')
at temp.getBooks(temp.bal:80)
at temp.main(temp.bal:90)
at $_init.$moduleExecute(.)
at $_init.$lambda$$moduleExecute$(.)
at io.ballerina.runtime.internal.scheduling.SchedulerItem.execute(SchedulerItem.java:54)
at io.ballerina.runtime.internal.scheduling.Scheduler.run(Scheduler.java:320)
at io.ballerina.runtime.internal.scheduling.Scheduler.runSafely(Scheduler.java:287)
at java.base/java.lang.Thread.run(Thread.java:833)
Description
$title.
May apply to other clients too.
Steps to Reproduce
The
is
check should never evaluate to true, should it? But it evaluates to true.Then if there's an error (e.g., mismatched column/record names), crashes
Version
2201.10.0
Environment Details (with versions)
No response