message: Close pool after failed refresh
diff: @@ -276,7 +276,12 @@ pub mod refresh_command {
  Ok(_) => {
  println_succ!("Pool \"{}\" has been refreshed", pool_name);
  Ok(())
  - },
  + }
  + Err(ref err) if err.error_code == ErrorCode::PoolLedgerTimeout => {
  + println_err!("Cannot refresh pool. Transaction response has not been received");
  + close_pool(ctx, pool_handle, &pool_name)
  + .map(|_| println_err!("Pool \"{}\" has been disconnected", pool_name))
  + }
  Err(err) => {
  handle_indy_error(err, None, None, None);
  Err(())
  @@ -298,28 +303,27 @@ pub mod disconnect_command {
  fn execute(ctx: &CommandContext, params: &CommandParams) -> Result<(), ()> {
  trace!("execute >> ctx {:?} params {:?}", ctx, params);
  - let (handle, name) = if let Some(pool) = get_connected_pool(ctx) {
  - pool
  - } else {
  - println_err!("There is no connected pool now");
  - return Err(());
  - };
  + let (handle, name) = ensure_connected_pool(ctx)?;
  - let res = match Pool::close(handle) {
  + let res = close_pool(ctx, handle, &name)
  + .map(|_| println_err!("Pool \"{}\" has been disconnected", name));
  +
  + trace!("execute << {:?}", res);
  + res
  + }
  +}
  +
  +fn close_pool(ctx: &CommandContext, handle: i32, name: &str) -> Result<(), ()> {
  + match Pool::close(handle) {
  Ok(()) => {
  set_connected_pool(ctx, None);
  set_transaction_author_info(ctx, None);
  - println_succ!("Pool \"{}\" has been disconnected", name);
  Ok(())
  }
  Err(err) => {
  handle_indy_error(err, None, Some(&name), None);
  Err(())
  }
  - };
  -
  - trace!("execute << {:?}", res);
  - res
  }
  }
  