mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
9bd47bf17c
cty doesn't have a native string representation of a cty.Path because it is the layer below any particular syntax, but up here in Terraform land we know that we use HCL native syntax and so we can format a string in a HCL-ish way for familiarity to the user. We'll use this form automatically when such an error is used directly as a diagnostic, but we also expose the function publicly so that other code that incorporates errors into diagnostic detail strings can apply the same formatting.
24 lines
446 B
Go
24 lines
446 B
Go
package tfdiags
|
|
|
|
// nativeError is a Diagnostic implementation that wraps a normal Go error
|
|
type nativeError struct {
|
|
err error
|
|
}
|
|
|
|
var _ Diagnostic = nativeError{}
|
|
|
|
func (e nativeError) Severity() Severity {
|
|
return Error
|
|
}
|
|
|
|
func (e nativeError) Description() Description {
|
|
return Description{
|
|
Summary: FormatError(e.err),
|
|
}
|
|
}
|
|
|
|
func (e nativeError) Source() Source {
|
|
// No source information available for a native error
|
|
return Source{}
|
|
}
|