Skip to content

Commit a96ae64

Browse files
authored
Merge pull request #948 from Geode-solutions/fix/serialize-attribute
fix(Attribute): add exception if serialize failed
2 parents 53cdf19 + 6c25beb commit a96ae64

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/geode/basic/attribute_manager.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,30 @@ namespace geode
313313
template < typename Archive >
314314
void serialize( Archive &archive )
315315
{
316-
archive.ext( *this,
317-
Growable< Archive, Impl >{
318-
{ []( Archive &local_archive, Impl &impl ) {
319-
local_archive.value4b( impl.nb_elements_ );
320-
local_archive.ext( impl.attributes_,
321-
bitsery::ext::StdMap{ impl.attributes_.max_size() },
322-
[]( Archive &local_archive2, std::string &name,
323-
std::shared_ptr< AttributeBase > &attribute ) {
324-
local_archive2.text1b( name, name.max_size() );
316+
archive.ext(
317+
*this, Growable< Archive, Impl >{ { []( Archive &local_archive,
318+
Impl &impl ) {
319+
local_archive.value4b( impl.nb_elements_ );
320+
local_archive.ext( impl.attributes_,
321+
bitsery::ext::StdMap{ impl.attributes_.max_size() },
322+
[]( Archive &local_archive2, std::string &name,
323+
std::shared_ptr< AttributeBase > &attribute ) {
324+
local_archive2.text1b( name, name.max_size() );
325+
try
326+
{
325327
local_archive2.ext(
326328
attribute, bitsery::ext::StdSmartPtr{} );
327-
} );
328-
} } } );
329+
}
330+
catch( ... )
331+
{
332+
throw OpenGeodeException{
333+
"[AttributeManager::serialize] Cannot "
334+
"serialize attribute ",
335+
name, " holding type ", attribute->type()
336+
};
337+
}
338+
} );
339+
} } } );
329340
}
330341

331342
private:

0 commit comments

Comments
 (0)