Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 69d95e8

Browse files
authored
display -> display_chain (#195)
Fixes #180
1 parent 52977e1 commit 69d95e8

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22

3+
- [Rename `ChanedError::display` to `display_chain`](https://github.com/brson/error-chain/issues/180)
34
- [Add a new method for `Error`: `chain_err`.](https://github.com/brson/error-chain/pull/141)
45
- [Allow `chain_err` to be used on `Option<T>`](https://github.com/brson/error-chain/pull/156)
56
- [Add support for creating an error chain on boxed trait errors (`Box<Error>`)](https://github.com/brson/error-chain/pull/156)

examples/quickstart.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ fn main() {
4646

4747
// The above main gives you maximum control over how the error is
4848
// formatted. If you don't care (i.e. you want to display the full
49-
// error during an assert) you can just call the `display` method
49+
// error during an assert) you can just call the `display_chain` method
5050
// on the error object
5151
#[allow(dead_code)]
5252
fn alternative_main() {
5353
if let Err(ref e) = run() {
5454
use std::io::Write;
55-
use error_chain::ChainedError; // trait which holds `display`
55+
use error_chain::ChainedError; // trait which holds `display_chain`
5656
let stderr = &mut ::std::io::stderr();
5757
let errmsg = "Error writing to stderr";
5858

59-
writeln!(stderr, "{}", e.display()).expect(errmsg);
59+
writeln!(stderr, "{}", e.display_chain()).expect(errmsg);
6060
::std::process::exit(1);
6161
}
6262
}

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
//!
6262
//! * Instead of defining the custom `Error` type as an enum, it is a
6363
//! struct containing an `ErrorKind` (which defines the
64-
//! `description` and `display` methods for the error), an opaque,
64+
//! `description` and `display_chain` methods for the error), an opaque,
6565
//! optional, boxed `std::error::Error + Send + 'static` object
6666
//! (which defines the `cause`, and establishes the links in the
6767
//! error chain), and a `Backtrace`.
@@ -390,7 +390,7 @@
390390
//!
391391
//! ```
392392
//! # #[macro_use] extern crate error_chain;
393-
//! use error_chain::ChainedError; // for e.display()
393+
//! use error_chain::ChainedError; // for e.display_chain()
394394
//!
395395
//! error_chain! {
396396
//! errors {
@@ -414,7 +414,7 @@
414414
//! assert_eq!(e.to_string(), "invalid toolchain name: 'xyzzy'");
415415
//!
416416
//! // Get the full cause and backtrace:
417-
//! println!("{}", e.display().to_string());
417+
//! println!("{}", e.display_chain().to_string());
418418
//! // Error: invalid toolchain name: 'xyzzy'
419419
//! // Caused by: invalid digit found in string
420420
//! // stack backtrace:
@@ -550,8 +550,8 @@ pub trait ChainedError: error::Error + Send + 'static {
550550
/// context of this error.
551551
///
552552
/// The full cause chain and backtrace, if present, will be printed.
553-
fn display<'a>(&'a self) -> Display<'a, Self> {
554-
Display(self)
553+
fn display_chain<'a>(&'a self) -> DisplayChain<'a, Self> {
554+
DisplayChain(self)
555555
}
556556

557557
/// Extends the error chain with a new entry.
@@ -573,9 +573,9 @@ pub trait ChainedError: error::Error + Send + 'static {
573573

574574
/// A struct which formats an error for output.
575575
#[derive(Debug)]
576-
pub struct Display<'a, T: 'a + ?Sized>(&'a T);
576+
pub struct DisplayChain<'a, T: 'a + ?Sized>(&'a T);
577577

578-
impl<'a, T> fmt::Display for Display<'a, T>
578+
impl<'a, T> fmt::Display for DisplayChain<'a, T>
579579
where T: ChainedError
580580
{
581581
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {

src/quick_main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ macro_rules! quick_main {
4747
::std::process::exit(match $main() {
4848
Ok(ret) => $crate::ExitCode::code(ret),
4949
Err(ref e) => {
50-
write!(&mut ::std::io::stderr(), "{}", $crate::ChainedError::display(e))
50+
write!(&mut ::std::io::stderr(), "{}", $crate::ChainedError::display_chain(e))
5151
.expect("Error writing to stderr");
5252

5353
1

0 commit comments

Comments
 (0)