Helper class for instantiating errors returned. from the service.
 /// <summary>
 /// Returns an exception wrapping a fault response indicating that an unknown internal failure occurred.
 /// </summary>
 /// <param name="faultSource">Source to use when creating ServiceFaults.</param>
 /// <returns>Exception wrapping the fault response.</returns>
 public static HttpResponseException UnknownInternalFailureException(string faultSource)
 {
     return(ServiceFault.InternalServerError(
                faultSource,
                UnknownInternalFailure,
                "The service has encountered an unknown internal server error."));
 }
 /// <summary>
 /// Returns exception when the Iap validation fails.
 /// </summary>
 /// <param name="details">Fault message.</param>
 /// <returns>Exception wrapping the fault.</returns>
 public static HttpResponseException IapValidationException(string details)
 {
     return(ServiceFault.BadRequest(
                Source,
                IapValidationError,
                "Iap could not be validated.",
                details));
 }
 /// <summary>
 /// Returns exception when a duplicate category is found during category
 /// creation.
 /// </summary>
 /// <param name="details">Fault inner message.</param>
 /// <returns>Exception wrapping the fault.</returns>
 public static HttpResponseException DuplicateCategoryException(string details)
 {
     return(ServiceFault.Forbidden(
                Source,
                DuplicateCategory,
                "Category of the same name exists.",
                details));
 }
 /// <summary>
 /// Returns exception when there is an exception calling data layer.
 /// </summary>
 /// <param name="details">Fault inner message.</param>
 /// <returns>Exception wrapping the fault.</returns>
 public static HttpResponseException DataLayerException(string details)
 {
     return(ServiceFault.InternalServerError(
                Source,
                DataLayerError,
                "An unknown error occurred while communicating with data layer.",
                details));
 }
 /// <summary>
 /// Returns exception when the current authenticated user fetched from Azure Mobile Service is null.
 /// </summary>
 /// <returns>Exception wrapping the fault.</returns>
 public static HttpResponseException UserNullException()
 {
     return(ServiceFault.Forbidden(
                Source,
                UserNullError,
                "This can only be performed by signed in clients.",
                null));
 }
 /// <summary>
 /// Returns exception when the current operation will overdraw user balance.
 /// </summary>
 /// <returns>Exception wrapping the fault.</returns>
 public static HttpResponseException UserBalanceTooLow()
 {
     return(ServiceFault.Forbidden(
                Source,
                UserBalanceTooLowForOperation,
                "User's balance is too low for this operation.",
                null));
 }
 /// <summary>
 /// Returns exception when the current user isn't allowed to perform this operation.
 /// </summary>
 /// <returns>Exception wrapping the fault.</returns>
 public static HttpResponseException NotAllowed()
 {
     return(ServiceFault.Forbidden(
                Source,
                IncorrectUser,
                "The logged in user does not have access to perform this operation.",
                null));
 }
 /// <summary>
 /// Returns an exception wrapping a fault response indicating that the Uri Id and the request body Id differ.
 /// </summary>
 /// <param name="pathArgumentId">Id from the Uri path argument.</param>
 /// <param name="requestId">Id from the request body.</param>
 /// <returns>Exception wrapping the fault response.</returns>
 public static HttpResponseException IdMismatchException(string pathArgumentId, string requestId)
 {
     return(ServiceFault.BadRequest(
                Source,
                IdMismatch,
                "The ID value present in the URI differs from the one present in the request body.",
                pathArgumentId,
                requestId));
 }