From c24fc3005da9fbc4fc52dbf190074713ee96914c Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Mon, 3 Oct 2016 15:35:26 -0500 Subject: [PATCH 1/2] docs: add section on error values to resource author's guide --- docs_source/content/resource-authors-guide.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs_source/content/resource-authors-guide.md b/docs_source/content/resource-authors-guide.md index 3ed21557d..c24977037 100644 --- a/docs_source/content/resource-authors-guide.md +++ b/docs_source/content/resource-authors-guide.md @@ -86,6 +86,14 @@ 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 +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. + ## Preparer Before you can use your resource, it has to be deserialized from HCL. For this, From 2e2830f6b92729e8f78fc1122930874690631a78 Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Mon, 3 Oct 2016 15:54:55 -0500 Subject: [PATCH 2/2] docs: be explicit about choosing an error handling option --- docs_source/content/resource-authors-guide.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs_source/content/resource-authors-guide.md b/docs_source/content/resource-authors-guide.md index c24977037..dc84fcfb5 100644 --- a/docs_source/content/resource-authors-guide.md +++ b/docs_source/content/resource-authors-guide.md @@ -92,7 +92,13 @@ 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 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. +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. ## Preparer