public Result Authenticate(UserDataObject user) {//authenticates new user try { UserBusinessLayer userBusiness = new UserBusinessLayer(); return(userBusiness.VerifyUser(user)); } catch (Exception e) { if (e.Message == "wrongkey") { Result ErrorObj = new Result(); ErrorObj.Status = "Failure"; ErrorObj.ExceptionDetails = "Invalid Api Key"; ErrorObj.ExceptionType = "AuthorizationException"; throw new WebFaultException <Result>(ErrorObj, System.Net.HttpStatusCode.Unauthorized); } else { Result obj = new Result(); obj.Status = "Failure"; obj.Message = "Bad Parameters"; throw new WebFaultException <Result>(obj, System.Net.HttpStatusCode.InternalServerError); } } }