コード例 #1
0
        /// <summary>
        /// Reports the given issue to the current active backend.
        /// Certain properties such as the environment and stacktrace are being resolved automatically,
        /// if you leave them blank/null.
        /// 
        /// </summary>
        /// <param name="report">The issue report which will be sent to the backend.</param>
        /// <exception cref="ReportSendException">Thrown when there was a problem sending the report to the backend.</exception>
        public async Task ReportIssueAsync(IssueReport report)
        {
            if(string.IsNullOrEmpty(ActiveBackend))throw new ReportSendException("You have to set an active report backend first before using the report method!");

            await PrepareIssueReportAsync(report);

            if (_reportBackends.ContainsKey(ActiveBackend))
            {
                var backend = _reportBackends[ActiveBackend];
                try
                {
                    await backend.SendIssueReportAsync(report);
                }
                catch (Exception e)
                {
                    throw new ReportSendException("Failed to send issue report using provider " + backend.GetType().Name, e);
                }
            }
            else
            {
                throw new ReportSendException(string.Format("No report backend found with id '{0}'", ActiveBackend));
            }
        }
コード例 #2
0
        protected async virtual Task PrepareIssueReportAsync(IssueReport report)
        {
            if (report.Environment == null)
            {
                report.Environment = ResolveCurrentEnvironmentDetail();
            }

            if (report.Stacktrace == null)
            {
                report.Stacktrace = await ResolveCurrentStacktraceAsync();
            }
        }