File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -400,6 +400,26 @@ pub fn warning(message: &str) {
400
400
emit ( "warning" , message) ;
401
401
}
402
402
403
+ /// The `error` instruction tells Cargo to display an error after the build script has finished
404
+ /// running, and then fail the build.
405
+ ///
406
+ /// <div class="warning">
407
+ ///
408
+ /// Build script libraries should carefully consider if they want to use [`error`] versus
409
+ /// returning a `Result`. It may be better to return a `Result`, and allow the caller to decide if the
410
+ /// error is fatal or not. The caller can then decide whether or not to display the `Err` variant
411
+ /// using [`error`].
412
+ ///
413
+ /// </div>
414
+ #[ doc = respected_msrv ! ( "1.84" ) ]
415
+ #[ track_caller]
416
+ pub fn error ( message : & str ) {
417
+ if message. contains ( '\n' ) {
418
+ panic ! ( "cannot emit warning: message contains newline" ) ;
419
+ }
420
+ emit ( "error" , message) ;
421
+ }
422
+
403
423
/// Metadata, used by `links` scripts.
404
424
#[ track_caller]
405
425
pub fn metadata ( key : & str , val : & str ) {
You can’t perform that action at this time.
0 commit comments