package envs import ( "strings" ) // Error conforms to a stdlib error interface. func (e *EnvErrNoVal) Error() (errStr string) { var sb *strings.Builder = new(strings.Builder) sb.WriteString("the variable '") sb.WriteString(e.VarName) sb.WriteString("' was ") if sb.WasFound { sb.WriteString("found") } else { sb.WriteString("not found") } if e.WasRequiredNonEmpty && e.WasFound { sb.WriteString(" but is empty and was required to be non-empty") } errStr = sb.String() return }