private static bool AddError(ErrorSubmitRequest request) {
            var errorText = Decode(request.Error);
            var errorId = request.ErrorId;
            var sourceId = request.SourceId;
            var infoUrl = request.InfoUrl;

            var infoUrlPath = string.IsNullOrWhiteSpace(infoUrl) ? string.Empty : new Uri(infoUrl).AbsoluteUri;

            var section = ConfigurationManager.GetSection("elmahr") as RootSection;
            var hasSection = section != null;
            if (!hasSection) return false;

            var error = (from _ in new[] { errorText }
                         let hasSource = section.Applications.Any(a => a.SourceId == sourceId)
                         let secret = hasSource ? section.Applications.Single(a => a.SourceId == sourceId).Secret : string.Empty
                         let hasSecret = !string.IsNullOrWhiteSpace(secret)
                         select hasSecret ? Crypto.DecryptStringAes(errorText, secret) : errorText)
                .FirstOrDefault();

            var payload = Error.ProcessAndAppendError(sourceId, errorId, error, infoUrlPath, ErrorCatcher(infoUrlPath), true);

            if (payload != null) {
                Hub.Log(string.Format("Received error from {0}: {1}", payload.GetApplication().ApplicationName, payload.Message));
            }

            return true;
        }
        private static ErrorSubmitResponse PostError(ErrorSubmitRequest request) {
            if (AddError(request)) {
                return new ErrorSubmitResponse {
                    Status = 1,
                    StatusMessage = "OK"
                };
            }

            return new ErrorSubmitResponse {
                Status = 2,
                StatusMessage = "FAILED"
            };
        }
 public ErrorSubmitResponse Post(ErrorSubmitRequest errorSubmitRequest) {
     RestRequest request;
     var client = PrepareRestClientWithRequestBody(errorSubmitRequest, NANCYAPI_SUBMITERROR, out request);
     IRestResponse<ErrorSubmitResponse> response = client.Post<ErrorSubmitResponse>(request);
     return response.Data;
 }