Handle and catch Ecto errors / exceptions

The output you posted looks like what would happen if the caller of list_books tried to use the CastError where it expected a list, something like:

Enum.each(list_books(filters), fn book -> ... end)

since IO.inspect returns its argument.