@@ -49,10 +49,14 @@ impl ContentTokenization {
4949 crate :: validation:: AddressValidator :: validate ( env, & creator) . unwrap ( ) ;
5050
5151 // Metadata validation (if title/description were String, we'd use StringValidator)
52- // Since they are Bytes, we check length
53- crate :: validation:: BytesValidator :: validate_length ( & title, 1 , 100 ) . unwrap ( ) ;
54- crate :: validation:: BytesValidator :: validate_length ( & description, 1 , 1000 ) . unwrap ( ) ;
55- crate :: validation:: BytesValidator :: validate_length ( & content_hash, 32 , 32 ) . unwrap ( ) ;
52+ // Since they are Bytes, we check length. Propagate as a proper
53+ // contract error instead of panicking the invocation (#485).
54+ crate :: validation:: BytesValidator :: validate_length ( & title, 1 , 100 )
55+ . map_err ( |_| TokenizationError :: InvalidMetadata ) ?;
56+ crate :: validation:: BytesValidator :: validate_length ( & description, 1 , 1000 )
57+ . map_err ( |_| TokenizationError :: InvalidMetadata ) ?;
58+ crate :: validation:: BytesValidator :: validate_length ( & content_hash, 32 , 32 )
59+ . map_err ( |_| TokenizationError :: InvalidMetadata ) ?;
5660
5761 if royalty_percentage > 100 {
5862 panic ! ( "Royalty percentage cannot exceed 100" ) ;
0 commit comments