Error handling in mirroring script