Handle failures correctly. Return error information when errors occur.