replace throwing exceptions in distribute pot function by error handling with error messages