Index: trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- trunk/src/VBox/Main/MachineImpl.cpp	(revision 14857)
+++ trunk/src/VBox/Main/MachineImpl.cpp	(revision 14858)
@@ -4159,5 +4159,5 @@
     {
         if (mData->mRegistered)
-            return setError (E_FAIL,
+            return setError (VBOX_E_INVALID_OBJECT_STATE,
                 tr ("The machine '%ls' with UUID {%s} is already registered"),
                 mUserData->mName.raw(),
@@ -4167,5 +4167,5 @@
     {
         if (mData->mMachineState == MachineState_Saved)
-            return setError (E_FAIL,
+            return setError (VBOX_E_INVALID_VM_STATE,
                 tr ("Cannot unregister the machine '%ls' because it "
                     "is in the Saved state"),
@@ -4176,5 +4176,5 @@
             snapshotCount = mData->mFirstSnapshot->descendantCount() + 1;
         if (snapshotCount)
-            return setError (E_FAIL,
+            return setError (VBOX_E_INVALID_OBJECT_STATE,
                 tr ("Cannot unregister the machine '%ls' because it "
                     "has %d snapshots"),
@@ -4182,5 +4182,5 @@
 
         if (mData->mSession.mState != SessionState_Closed)
-            return setError (E_FAIL,
+            return setError (VBOX_E_INVALID_OBJECT_STATE,
                 tr ("Cannot unregister the machine '%ls' because it has an "
                     "open session"),
@@ -4188,5 +4188,5 @@
 
         if (mHDData->mAttachments.size() != 0)
-            return setError (E_FAIL,
+            return setError (VBOX_E_INVALID_OBJECT_STATE,
                 tr ("Cannot unregister the machine '%ls' because it "
                     "has %d hard disks attached"),
Index: trunk/src/VBox/Main/VirtualBoxImpl.cpp
===================================================================
--- trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 14857)
+++ trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 14858)
@@ -962,5 +962,5 @@
          *  or opened by OpenMachine() or loaded during startup
          */
-        return setError (E_FAIL,
+        return setError (VBOX_E_INVALID_OBJECT_STATE,
             tr ("The machine named '%ls' is not created within this "
                 "VirtualBox instance"), name.raw());
@@ -1041,5 +1041,5 @@
     HRESULT rc = machine
         ? S_OK
-        : setError (E_INVALIDARG,
+        : setError (VBOX_E_FILE_ERROR,
             tr ("Could not find a registered machine named '%ls'"), aName);
 
@@ -2635,5 +2635,5 @@
     if (aSetError && !found)
     {
-        setError (E_INVALIDARG,
+        setError (VBOX_E_FILE_ERROR,
             tr ("Could not find a registered machine with UUID {%RTuuid}"),
             aId.raw());
Index: trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 14857)
+++ trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 14858)
@@ -1484,4 +1484,7 @@
 
         @deprecated Will be removed soon.
+        <result name="VBOX_E_FILE_ERROR">
+          Settings file name invalid, not found or sharing violation.
+        </result>
       </desc>
       <param name="settingsFile" type="wstring" dir="in">
@@ -1515,4 +1518,8 @@
         </note>
 
+        <result name="VBOX_E_INVALID_OBJECT_STATE">
+          Virtual machine was not created within this VirtualBox instance.
+        </result>
+
       </desc>
       <param name="machine" type="IMachine" dir="in"/>
@@ -1522,5 +1529,11 @@
       <desc>
         Attempts to find a virtual machine given its UUID.
-        To look up a machine by name, use <link to="IVirtualBox::findMachine" /> instead.
+        To look up a machine by name, use <link to="IVirtualBox::findMachine" />
+        instead.
+
+        <result name="VBOX_E_FILE_ERROR">
+          Could not find registered machine matching @a id.
+        </result>
+
       </desc>
       <param name="id" type="uuid" dir="in"/>
@@ -1531,5 +1544,11 @@
       <desc>
         Attempts to find a virtual machine given its name.
-        To look up a machine by UUID, use <link to="IVirtualBox::getMachine" /> instead.
+        To look up a machine by UUID, use <link to="IVirtualBox::getMachine" />
+        instead.
+
+        <result name="VBOX_E_FILE_ERROR">
+          Could not find registered machine matching @a name.
+        </result>
+
       </desc>
       <param name="name" type="wstring" dir="in"/>
@@ -1563,4 +1582,14 @@
           <b>any</b> method will return the "Object not ready" error.
         </note>
+
+        <result name="VBOX_E_FILE_ERROR">
+          Could not find registered machine matching @a id.
+        </result>
+        <result name="VBOX_E_INVALID_VM_STATE">
+          Machine is in Saved state.
+        </result>
+        <result name="VBOX_E_INVALID_OBJECT_STATE">
+          Machine has snapshot or open session or hard disk attached.
+        </result>
 
       </desc>
