errorreporter

package
v0.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2022 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Overview

Package errorreporter makes all validation errors visible to callers so they can report or handle them as appropriate for the surrounding system.

Index

Constants

View Source
const (
	IssueSeverityWarning = IssueSeverityCode("warning")
	IssueSeverityError   = IssueSeverityCode("error")
	ValueIssueTypeCode   = IssueTypeCode("VALUE")
)

FHIR versions and Issue codes for operation outcome.

Variables

View Source
var (
	// R3IssueSeverityCodeMap maps IssueSeverityCode to R3IssueSeverityCode
	R3IssueSeverityCodeMap = map[IssueSeverityCode]c3pb.IssueSeverityCode_Value{
		IssueSeverityError:   c3pb.IssueSeverityCode_ERROR,
		IssueSeverityWarning: c3pb.IssueSeverityCode_WARNING,
	}
	// R3OutcomeCodeMap maps IssueTypeCode to R3IssueTypeCode_Value
	R3OutcomeCodeMap = map[IssueTypeCode]c3pb.IssueTypeCode_Value{
		ValueIssueTypeCode: c3pb.IssueTypeCode_VALUE,
	}
	// R4IssueSeverityCodeMap maps IssueSeverityCode to R4IssueSeverityCode
	R4IssueSeverityCodeMap = map[IssueSeverityCode]c4pb.IssueSeverityCode_Value{
		IssueSeverityError:   c4pb.IssueSeverityCode_ERROR,
		IssueSeverityWarning: c4pb.IssueSeverityCode_WARNING,
	}
	// R4OutcomeCodeMap maps IssueTypeCode to R4IssueTypeCode_Value
	R4OutcomeCodeMap = map[IssueTypeCode]c4pb.IssueTypeCode_Value{
		ValueIssueTypeCode: c4pb.IssueTypeCode_VALUE,
	}
)

Functions

This section is empty.

Types

type BasicErrorReporter

type BasicErrorReporter struct {
	Errors []*error
}

BasicErrorReporter simply stores all errors during valudation.

This is primarily for legacy use; most users should use an OperationOutcomeErrorHandler or their own implementation.

func NewBasicErrorReporter

func NewBasicErrorReporter() *BasicErrorReporter

NewBasicErrorReporter creates a basic error reporter

func (*BasicErrorReporter) ReportValidationError

func (be *BasicErrorReporter) ReportValidationError(_ string, err error) error

ReportValidationError stores the error by appending it to the errors field.

func (*BasicErrorReporter) ReportValidationWarning

func (be *BasicErrorReporter) ReportValidationWarning(elementPath string, err error) error

ReportValidationWarning does nothing.

type ErrorReporter

type ErrorReporter interface {
	// ReportValidationError reports validation errors occurred during validation.
	//
	// If the error can be satisfactorily reported it should return nil, instructing
	// the FHIR validation logic to proceed.
	//
	// Conversely, if this returns an error, it means an error was encountered while
	// attempting to handle the original error, indicating a failure mode of the
	// ErrorReporter itself.
	ReportValidationError(elementPath string, err error) error
	// ReportValidationError reports validation warning occurred during validation.
	//
	// If the error can be satisfactorily reported, it should return nil, instructing
	// the FHIR validation logic to proceed.
	//
	// Conversely, if this returns an error, it means an error was encountered while
	// attempting to handle the original error, indicating a failure mode of the
	// ErrorReporter itself.
	ReportValidationWarning(elementPath string, err error) error
}

An ErrorReporter can be used to handle validation errors in the manner of the caller's choosing.

type IssueSeverityCode

type IssueSeverityCode string

IssueSeverityCode describes the severity of an operation output issue.

type IssueTypeCode

type IssueTypeCode string

IssueTypeCode describes the type of an operation output issue.

type MultiVersionOperationOutcome

type MultiVersionOperationOutcome struct {
	Version   fhirversion.Version
	R3Outcome *r3pb.OperationOutcome
	R4Outcome *r4outcomepb.OperationOutcome
}

MultiVersionOperationOutcome encompasses Operations of multiple FHIR versions.

type OperationErrorReporter

type OperationErrorReporter struct {
	Outcome *MultiVersionOperationOutcome
}

OperationErrorReporter is an implementation of ErrorReporter. It makes validation errors visible to callers by preserving errors in a MultiVersionOperationOutcome. TODO: Add examples

func NewOperationErrorReporter

func NewOperationErrorReporter(ver fhirversion.Version) *OperationErrorReporter

NewOperationErrorReporter returns an OperationErrorRerporter with specified fhir version.

func (*OperationErrorReporter) ReportValidationError

func (oe *OperationErrorReporter) ReportValidationError(elementPath string, err error) error

ReportValidationError reports an issue at "Error" severity, indicating that the operation should be considered a failure.

func (*OperationErrorReporter) ReportValidationWarning

func (oe *OperationErrorReporter) ReportValidationWarning(elementPath string, err error) error

ReportValidationWarning reports an issue at "Warning" severity, indicating that the operation encountered an issue, but can still be considered successful.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL