Exemple #1
0
        public static OperationOutcome Error(this OperationOutcome outcome, Exception exception)
        {
            string message;

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

            var baseResult = outcome.Error(message);

            // Don't add a stack trace if this is an acceptable logical-level error
            if (!(exception is FhirServerException))
            {
                var stackTrace = new OperationOutcome.IssueComponent();
                stackTrace.Severity = OperationOutcome.IssueSeverity.Information;
                stackTrace.Details  = new CodeableConcept(null, null, exception.StackTrace);
                baseResult.Issue.Add(stackTrace);
            }

            return(baseResult);
        }
Exemple #2
0
        OperationOutcome CreateOutcome(Exception exception)
        {
            OperationOutcome outcome = new OperationOutcome().Init();
            Exception        e       = exception;

            do
            {
                outcome.Error(e);
                e = e.InnerException;
            }while (e != null);

            return(outcome);
        }