How to catch error Live streaming failed to start

I use iframe api, when my stream key is not valid anymore i see Live streaming failed to start - how catch this event and regenerate key ?