Add error handler only once

fixes #240