make an errorhandler for api