public static OperationOutcome Error(this OperationOutcome outcome, Exception exception)
        {
            string message;

            if (exception is SparkException)
            {
                message = exception.Message;
            }
            else
            {
                message = string.Format("{0}: {1}", exception.GetType().Name, exception.Message);
            }

            var baseResult = outcome.AddError(message);

            // Don't add a stacktrace if this is an acceptable logical-level error
            if (!(exception is SparkException))
            {
                var stackTrace = new OperationOutcome.OperationOutcomeIssueComponent();
                stackTrace.Severity = OperationOutcome.IssueSeverity.Information;
                stackTrace.Details  = exception.StackTrace;
                baseResult.Issue.Add(stackTrace);
            }

            return(baseResult);
        }
Пример #2
0
        public void AddIssue(string errorMessage, OperationOutcome.IssueSeverity severity = OperationOutcome.IssueSeverity.Error)
        {
            var newIssue = new OperationOutcome.OperationOutcomeIssueComponent()
            {
                Details = errorMessage, Severity = severity
            };

            outcome.Issue.Add(newIssue);
        }
        public static OperationOutcome Error(this OperationOutcome outcome, string message)
        {
            outcome.Init();

            var item = new OperationOutcome.OperationOutcomeIssueComponent();

            item.Severity = OperationOutcome.IssueSeverity.Error;
            item.Details  = message;
            outcome.Issue.Add(item);
            return(outcome);
        }
        private static OperationOutcome AddIssue(this OperationOutcome outcome, OperationOutcome.IssueSeverity severity, string message)
        {
            if (outcome.Issue == null)
            {
                outcome.Init();
            }

            var item = new OperationOutcome.OperationOutcomeIssueComponent();

            item.Severity = severity;
            item.Details  = message;
            outcome.Issue.Add(item);
            return(outcome);
        }
        public static OperationOutcome Message(this OperationOutcome outcome, string message)
        {
            if (outcome.Issue == null)
            {
                outcome.Init();
            }

            var item = new OperationOutcome.OperationOutcomeIssueComponent();

            item.Severity = OperationOutcome.IssueSeverity.Information;
            item.Details  = message;
            outcome.Issue.Add(item);
            return(outcome);
        }
Пример #6
0
        public void TestCardinality()
        {
            OperationOutcome oo = new OperationOutcome();
            validateErrorOrFail(oo,true);

            oo.Issue = new List<OperationOutcome.OperationOutcomeIssueComponent>();
            validateErrorOrFail(oo,true);

            var issue = new OperationOutcome.OperationOutcomeIssueComponent();

            oo.Issue.Add(issue);
            validateErrorOrFail(oo,true);

            issue.Severity = OperationOutcome.IssueSeverity.Information;
            FhirValidator.Validate(oo, true);
        }
Пример #7
0
        public void TestCardinality()
        {
            OperationOutcome oo = new OperationOutcome();

            validateErrorOrFail(oo, true);

            oo.Issue = new List <OperationOutcome.OperationOutcomeIssueComponent>();
            validateErrorOrFail(oo, true);

            var issue = new OperationOutcome.OperationOutcomeIssueComponent();

            oo.Issue.Add(issue);
            validateErrorOrFail(oo, true);

            issue.Severity = OperationOutcome.IssueSeverity.Information;
            validateErrorOrFail(oo, true);

            issue.Code = new CodeableConcept("http://somesystem.org/some", "bla");
            DotNetAttributeValidation.Validate(oo, true);
        }
Пример #8
0
        public void TestCardinality()
        {
            OperationOutcome oo = new OperationOutcome();

            validateErrorOrFail(oo, true);

            oo.Issue = new List <OperationOutcome.OperationOutcomeIssueComponent>();
            validateErrorOrFail(oo, true);

            var issue = new OperationOutcome.OperationOutcomeIssueComponent();

            oo.Issue.Add(issue);
            validateErrorOrFail(oo, true);

            issue.Severity = OperationOutcome.IssueSeverity.Information;
            validateErrorOrFail(oo, true);

            issue.Code = OperationOutcome.IssueType.Forbidden;

            DotNetAttributeValidation.Validate(oo, true);
        }