message: network-core: Augment server::block::BlockError with a cause box
  Enable optionally bundling an underlying error as a cause with
  BlockError.
diff: @@ -95,12 +95,45 @@ pub trait BlockService {
  /// Represents errors that can be returned by the block service.
  #[derive(Debug)]
  -pub struct BlockError(pub ErrorCode);
  +pub struct BlockError {
  + code: ErrorCode,
  + cause: Option<Box<dyn error::Error + Send + Sync>>,
  +}
  +
  +impl BlockError {
  + pub fn failed<E>(cause: E) -> Self
  + where
  + E: Into<Box<dyn error::Error + Send + Sync>>,
  + {
  + BlockError {
  + code: ErrorCode::Failed,
  + cause: Some(cause.into()),
  + }
  + }
  -impl error::Error for BlockError {}
  + pub fn with_code_and_cause<E>(code: ErrorCode, cause: E) -> Self
  + where
  + E: Into<Box<dyn error::Error + Send + Sync>>,
  + {
  + BlockError {
  + code,
  + cause: Some(cause.into()),
  + }
  + }
  +}
  +
  +impl error::Error for BlockError {
  + fn source(&self) -> Option<&(dyn error::Error + 'static)> {
  + if let Some(err) = &self.cause {
  + Some(&**err)
  + } else {
  + None
  + }
  + }
  +}
  impl fmt::Display for BlockError {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  - write!(f, "block service error: {}", self.0)
  + write!(f, "block service error: {}", self.code)
  }
  }
  