public int Divide(int a, int b) { try { return(a / b); } catch (DivideByZeroException ex) { var fault = new HelloFault { ErrorCode = "101", ErrorDescription = "Divide by Zero" }; throw new FaultException <HelloFault>(fault); } }
public string GetEmployeeName(int ID) { try { return("My name is John Doe"); } catch (Exception) { var fault = new HelloFault { ErrorCode = "99", ErrorDescription = "Please check values" }; throw new FaultException <HelloFault>(fault); } }
public Employee GetEmployee(int ID) { try { var allEmps = GetAllEmployees(); return(allEmps.First(x => x.ID == ID)); } catch (Exception ex) { var fault = new HelloFault { ErrorCode = "100", ErrorDescription = ex.Message }; throw new FaultException <HelloFault>(fault); } }