There is a second undocumented variant of that function which takes a "default" value. I'm not sure if its in 1.90 but definitely in 1.91, first beta of which will be out very soon.
So -
GetSpriteIdByName("name", -1) will return -1 if not found.
Also, in 1.91 there will be the following other useful functions:
sprite.SetSprite( spriteId );
sprite.SetSprite( "spriteName" ); // returns false if sprite not found, doesn't do anything to the sprite
and...
sprite.SetSprite( newCollection, spriteIdFromNewCollection );
sprite.SetSprite( newCollection, "spriteNameFromNewCollection" );