Patchwork D9319: rust-status: properly translate OSError to Python

login
register
mail settings
Submitter phabricator
Date Nov. 16, 2020, 4:02 p.m.
Message ID <differential-rev-PHID-DREV-vycd5jajm3se7nlivls2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47595/
State Superseded
Headers show

Comments

phabricator - Nov. 16, 2020, 4:02 p.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is probably never going to be called after the next few patches, but we
  might as well make sure this is done correctly for the future rewrite.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9319

AFFECTED FILES
  rust/hg-cpython/src/dirstate/status.rs

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-cpython/src/dirstate/status.rs b/rust/hg-cpython/src/dirstate/status.rs
--- a/rust/hg-cpython/src/dirstate/status.rs
+++ b/rust/hg-cpython/src/dirstate/status.rs
@@ -10,6 +10,7 @@ 
 //! `rustext.dirstate.status`.
 
 use crate::{dirstate::DirstateMap, exceptions::FallbackError};
+use cpython::exc::OSError;
 use cpython::{
     exc::ValueError, ObjectProtocol, PyBytes, PyErr, PyList, PyObject,
     PyResult, PyTuple, Python, PythonObject, ToPyObject,
@@ -89,6 +90,7 @@ 
 
             PyErr::new::<FallbackError, _>(py, &as_string)
         }
+        StatusError::IO(e) => PyErr::new::<OSError, _>(py, e.to_string()),
         e => PyErr::new::<ValueError, _>(py, e.to_string()),
     }
 }