happly icon indicating copy to clipboard operation
happly copied to clipboard

Improve exception message when trying to read list property as scalar

Open christian-rauch opened this issue 4 years ago • 2 comments

I have a custom element with a list property:

element track 572
property list uint16 uint32 vertex_index

When trying to read it via:

const std::vector<uint32_t> track_ids = tracks.getElement("track").getProperty<uint32_t>("vertex_index");

I am getting the exception:

PLY parser: property vertex_index cannot be coerced to requested type uint. Has type unit

which is a bit confusing, since it detects the correct type (Has type unit) but fails to convert the type to the same type (cannot be coerced to requested type uint).

Is this a bug in the conversion, or is the uint32 type just not supported?

christian-rauch avatar May 11 '21 10:05 christian-rauch

Ah, never mind. This is a list property and I tried to read it as a scalar property.

The correct call would be:

tracks.getElement("track").getListProperty<uint32_t>("vertex_index");

Maybe the exception should say something about list and scalar properties and not about the scalar type conversion.

christian-rauch avatar May 11 '21 10:05 christian-rauch

Thanks for filing! I'll convert this to a TODO to add a better error message.

nmwsharp avatar May 12 '21 12:05 nmwsharp