diff --git a/rust/hg-cpython/src/revlog.rs b/rust/hg-cpython/src/revlog.rs
index f9a52a9603f9201863ca1131c8a32c5cabf4d0b5_cnVzdC9oZy1jcHl0aG9uL3NyYy9yZXZsb2cucnM=..5807e3a8865e18c4e7adbe687f69938f55ef6be9_cnVzdC9oZy1jcHl0aG9uL3NyYy9yZXZsb2cucnM= 100644
--- a/rust/hg-cpython/src/revlog.rs
+++ b/rust/hg-cpython/src/revlog.rs
@@ -675,7 +675,9 @@
                         .expect("default header is broken")
                         .unwrap(),
                 )
-                .unwrap(),
+                .map_err(|e| {
+                    revlog_error_with_msg(py, e.to_string().as_bytes())
+                })?,
             ),
             RefCell::new(None),
             RefCell::new(None),
@@ -1052,6 +1054,21 @@
     }
 }
 
+fn revlog_error_with_msg(py: Python, msg: &[u8]) -> PyErr {
+    match py
+        .import("mercurial.error")
+        .and_then(|m| m.get(py, "RevlogError"))
+    {
+        Err(e) => e,
+        Ok(cls) => PyErr::from_instance(
+            py,
+            cls.call(py, (PyBytes::new(py, msg),), None)
+                .ok()
+                .into_py_object(py),
+        ),
+    }
+}
+
 fn graph_error(py: Python, _err: hg::GraphError) -> PyErr {
     // ParentOutOfRange is currently the only alternative
     // in `hg::GraphError`. The C index always raises this simple ValueError.