When calling sizeof(T::DataType)
with abstract types, an error is thrown (as mentioned here Essentials · The Julia Language). But calling it with String
also throws an error.
I have proposed a fix to a YAXArrays package issue. The issue happens when the user creates an YAXArray{T,D} and, inside this package, sizeof(T)
is called. Because the DataType can be anything, sometimes it is AbstractType
or a String
and that causes the issue. Here’s the link to the issue Handling abstract types? · Issue #410 · JuliaDataCubes/YAXArrays.jl (github.com).
The thing is: because that doesn’t happen only with AbstractTypes, I can’t just check if isabstracttype(T)
before calling sizeof
. My approach was to catch the error, but it was pointed to me that this is not a good practice (https://discourse.julialang.org/t/please-stop-using-error-and-errorexception-in-packages-and-base/).
My questions are:
- Is there a way of checking if a DataType has a specific size before calling
sizeof
? - Is there a better way of catching this error?
- Is there another good approach I am missing here…?