code: func (diags Diagnostics) ErrWithWarnings() error {
  	if len(diags) == 0 {
  		return nil
  	}
  	if diags.HasErrors() {
  		return diags.Err()
  	}
  	return NonFatalError{diags}
  }
docs: // ErrWithWarnings is similar to Err except that it will also return a non-nil
  // error if the receiver contains only warnings.
  //
  // In the warnings-only situation, the result is guaranteed to be of dynamic
  // type NonFatalError, allowing diagnostics-aware callers to type-assert
  // and unwrap it, treating it as non-fatal.
  //
  // This should be used only in contexts where the caller is able to recognize
  // and handle NonFatalError. For normal callers that expect a lack of errors
  // to be signaled by nil, use just Diagnostics.Err.