github.com/opentofu/opentofu@v1.7.1/internal/tfdiags/error.go (about)

     1  // Copyright (c) The OpenTofu Authors
     2  // SPDX-License-Identifier: MPL-2.0
     3  // Copyright (c) 2023 HashiCorp, Inc.
     4  // SPDX-License-Identifier: MPL-2.0
     5  
     6  package tfdiags
     7  
     8  // nativeError is a Diagnostic implementation that wraps a normal Go error
     9  type nativeError struct {
    10  	err error
    11  }
    12  
    13  var _ Diagnostic = nativeError{}
    14  
    15  func (e nativeError) Severity() Severity {
    16  	return Error
    17  }
    18  
    19  func (e nativeError) Description() Description {
    20  	return Description{
    21  		Summary: FormatError(e.err),
    22  	}
    23  }
    24  
    25  func (e nativeError) Source() Source {
    26  	// No source information available for a native error
    27  	return Source{}
    28  }
    29  
    30  func (e nativeError) FromExpr() *FromExpr {
    31  	// Native errors are not expression-related
    32  	return nil
    33  }
    34  
    35  func (e nativeError) ExtraInfo() interface{} {
    36  	// Native errors don't carry any "extra information".
    37  	return nil
    38  }