I have the following problem:
I have a service method:
public bool EmployeeCanReiceivePayment(int employeeId) { ... int workingHours = this.GetEmployeeWorkingHours(employeeId); if(workingHours < N) { throw new EmployeeCannotReceivePaymentException(); } return true; } public int GetEmployeeWorkingHours(int employeeId) { //returns the number of working hours of the employee for the last month }
GetEmployeeWorkingHours is just one of the methods to check if the employee can receive salary (so there can be another reason for the employer not to pay). For each of this reasons I want to throw an exception with the appropriate information: Number of required working hours, number of the actual working hours etc..
The question is:
Is there a way to return an object or additional information with my Custom exception. And by additional information I mean an object or just several paramenters.