Manage errors with custom handler