Small fix in error handling

Small fix in error handling