Browse Source

Pass back failed path if it doesn't point to an AML object

This is useful when the error is produced within a parser (e.g. when
invoking a control method) and you don't know which object is missing.
Isaac Woods 5 years ago
parent
commit
301a74b948
1 changed files with 4 additions and 4 deletions
  1. 4 4
      aml_parser/src/lib.rs

+ 4 - 4
aml_parser/src/lib.rs

@@ -53,7 +53,7 @@ pub mod value;
 
 pub use crate::{name_object::AmlName, value::AmlValue};
 
-use alloc::collections::BTreeMap;
+use alloc::{collections::BTreeMap, string::String};
 use log::error;
 use parser::Parser;
 use pkg_length::PkgLength;
@@ -63,7 +63,7 @@ use value::Args;
 /// what this is actually used for, but this is ours.
 pub const AML_INTERPRETER_REVISION: u64 = 0;
 
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
 pub enum AmlError {
     /*
      * Errors produced parsing the AML stream.
@@ -84,7 +84,7 @@ pub enum AmlError {
      * Errors produced querying the namespace.
      */
     /// Produced when a path is given that does not point to an object in the AML namespace.
-    ObjectDoesNotExist,
+    ObjectDoesNotExist(String),
 }
 
 #[derive(Debug)]
@@ -147,7 +147,7 @@ impl AmlContext {
         let method = match self.lookup(path) {
             // Unfortunately, we have to clone the method object to end the borrow on the context.
             Some(object) => object.clone(),
-            None => return Err(AmlError::ObjectDoesNotExist),
+            None => return Err(AmlError::ObjectDoesNotExist(path.as_string())),
         };
 
         method.invoke(self, args)