Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add section on error values to resource author's guide #347

Merged
merged 2 commits into from
Oct 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs_source/content/resource-authors-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ these rules:
1. Otherwise, if there are any diffs which say that they contain a difference,
the Status will always show as having changes.

### Dealing with Errors

The default `Status` implementation has a `SetError(error)` method. When called,
it sets an appropriate error level and an internal error state that will be
Copy link
Contributor

@ryane ryane Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should you also return the error if you call SetError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I've added a section to clarify in ebd589c

presented to the user. You can also use the common Go patterm of returning `nil,
err` in your `Check` and `Apply` statements. Converge will call `SetError(err)`
automatically in this case. This gives you two options:

1. call `SetError` yourself.
1. return an error, which will be handled for you.

You shoud choose *one* of these options and do it consistently across as much of
your code as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, until #345 is merged, your error can be lost (regardless of whether you SetError or just return it) if the final plan phase HasChanges

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll consider that a blocker for this.

## Preparer

Before you can use your resource, it has to be deserialized from HCL. For this,
Expand Down