Skip to content

Commit

Permalink
Nil check error in diag.FromErr
Browse files Browse the repository at this point in the history
This allows following use cases:

```go
func foo() error {
    //...
}

func bar() diag.diagnostics {
    //...
    return diag.FromErr(foo())
}
```
  • Loading branch information
magodo committed Jul 7, 2020
1 parent b35892a commit 42455a8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/terraform-plugin-sdk.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions diag/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import "fmt"
// return diag.FromErr(err)
// }
func FromErr(err error) Diagnostics {
if err == nil {
return nil
}
return Diagnostics{
Diagnostic{
Severity: Error,
Expand Down

0 comments on commit 42455a8

Please sign in to comment.