@@ -252,23 +252,34 @@ impl ToAscObj<u32> for IndexForAscTypeId {
252252}
253253
254254#[ derive( Debug ) ]
255- pub struct DeterministicHostError ( Error ) ;
255+ pub enum DeterministicHostError {
256+ Gas ( Error ) ,
257+ Other ( Error ) ,
258+ }
256259
257260impl DeterministicHostError {
261+ pub fn gas ( e : Error ) -> Self {
262+ DeterministicHostError :: Gas ( e)
263+ }
264+
258265 pub fn inner ( self ) -> Error {
259- self . 0
266+ match self {
267+ DeterministicHostError :: Gas ( e) | DeterministicHostError :: Other ( e) => e,
268+ }
260269 }
261270}
262271
263272impl fmt:: Display for DeterministicHostError {
264273 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
265- self . 0 . fmt ( f)
274+ match self {
275+ DeterministicHostError :: Gas ( e) | DeterministicHostError :: Other ( e) => e. fmt ( f) ,
276+ }
266277 }
267278}
268279
269280impl From < Error > for DeterministicHostError {
270281 fn from ( e : Error ) -> DeterministicHostError {
271- DeterministicHostError ( e)
282+ DeterministicHostError :: Other ( e)
272283 }
273284}
274285
@@ -294,7 +305,11 @@ impl From<anyhow::Error> for HostExportError {
294305
295306impl From < DeterministicHostError > for HostExportError {
296307 fn from ( value : DeterministicHostError ) -> Self {
297- HostExportError :: Deterministic ( value. 0 )
308+ match value {
309+ // Until we are confident on the gas numbers, gas errors are not deterministic
310+ DeterministicHostError :: Gas ( e) => HostExportError :: Unknown ( e) ,
311+ DeterministicHostError :: Other ( e) => HostExportError :: Deterministic ( e) ,
312+ }
298313 }
299314}
300315
0 commit comments