Skip to content

Commit deb028f

Browse files
committed
Add a note to library authors regarding cargo::error
There was a concern raised about potential use of `cargo::error` by libraries, which could make it difficult for build script authors to decide what is an error. #10159 (comment)
1 parent 9ce30a6 commit deb028f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/doc/src/reference/build-scripts.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ to set the shared library version or the runtime-path.
319319
The `error` instruction tells Cargo to display an error after the build script
320320
has finished running, and then fail the build.
321321

322+
> Note: Build script libraries should carefully consider if they want to
323+
> use `cargo::error` versus returning a `Result`. It may be better to return
324+
> a `Result`, and allow the caller to decide if the error is fatal or not.
325+
> The caller can then decide whether or not to display the `Err` variant
326+
> using `cargo::error`.
327+
322328
> **MSRV:** Respected as of 1.82
323329
324330
### `cargo::warning=MESSAGE` {#cargo-warning}

0 commit comments

Comments
 (0)