github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/tfdiags/error.go (about)

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