Index: /trunk/src/VBox/Main/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 23663)
+++ /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 23664)
@@ -1511,6 +1511,6 @@
         else
             return setError(VBOX_E_INVALID_VM_STATE,
-                tr("Invalid machine state: %d (must be Running, Paused or Stuck)"),
-                mMachineState);
+                tr("Invalid machine state: %s (must be Running, Paused or Stuck)"),
+                Global::stringifyMachineState(mMachineState));
     }
 
@@ -1562,6 +1562,6 @@
     if (mMachineState != MachineState_Running)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Invalid machine state: %d"),
-            mMachineState);
+            tr("Invalid machine state: %s"),
+            Global::stringifyMachineState(mMachineState));
 
     /* protect mpVM */
@@ -1595,6 +1595,6 @@
     if (mMachineState != MachineState_Running)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Invalid machine state: %d)"),
-            mMachineState);
+            tr("Invalid machine state: %s"),
+            Global::stringifyMachineState(mMachineState));
 
     /* protect mpVM */
@@ -1630,6 +1630,6 @@
     if (mMachineState != MachineState_Paused)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Cannot resume the machine as it is not paused (machine state: %d)"),
-            mMachineState);
+            tr("Cannot resume the machine as it is not paused (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     /* protect mpVM */
@@ -1669,6 +1669,6 @@
     if (mMachineState != MachineState_Running)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Invalid machine state: %d)"),
-            mMachineState);
+            tr("Invalid machine state: %s"),
+            Global::stringifyMachineState(mMachineState));
 
     /* protect mpVM */
@@ -1710,6 +1710,6 @@
     if (mMachineState != MachineState_Running)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Invalid machine state: %d)"),
-            mMachineState);
+            tr("Invalid machine state: %s"),
+            Global::stringifyMachineState(mMachineState));
 
     /* protect mpVM */
@@ -1754,6 +1754,6 @@
     if (mMachineState != MachineState_Running)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Invalid machine state %d when checking if the guest entered the ACPI mode)"),
-            mMachineState);
+            tr("Invalid machine state %s when checking if the guest entered the ACPI mode)"),
+            Global::stringifyMachineState(mMachineState));
 
     /* protect mpVM */
@@ -1789,6 +1789,6 @@
     if (mMachineState != MachineState_Running)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Invalid machine state: %d)"),
-            mMachineState);
+            tr("Invalid machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     /* protect mpVM */
@@ -1832,6 +1832,6 @@
     {
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Cannot save the execution state as the machine is not running or paused (machine state: %d)"),
-            mMachineState);
+            tr("Cannot save the execution state as the machine is not running or paused (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
     }
 
@@ -1969,6 +1969,6 @@
         mMachineState != MachineState_Aborted)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Cannot adopt the saved machine state as the machine is not in Powered Off or Aborted state (machine state: %d)"),
-            mMachineState);
+            tr("Cannot adopt the saved machine state as the machine is not in Powered Off or Aborted state (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     return mControl->AdoptSavedState(aSavedStateFile);
@@ -1984,6 +1984,6 @@
     if (mMachineState != MachineState_Saved)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Cannot discard the machine state as the machine is not in the saved state (machine state: %d)"),
-            mMachineState);
+            tr("Cannot discard the machine state as the machine is not in the saved state (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     HRESULT rc = S_OK;
@@ -2108,6 +2108,6 @@
         mMachineState != MachineState_Paused)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Cannot attach a USB device to the machine which is not running or paused (machine state: %d)"),
-            mMachineState);
+            tr("Cannot attach a USB device to the machine which is not running or paused (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     /* protect mpVM */
@@ -2286,6 +2286,6 @@
     if (mMachineState > MachineState_Paused)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Cannot create a transient shared folder on the machine while it is changing the state (machine state: %d)"),
-            mMachineState);
+            tr("Cannot create a transient shared folder on the machine while it is changing the state (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     ComObjPtr<SharedFolder> sharedFolder;
@@ -2348,6 +2348,6 @@
     if (mMachineState > MachineState_Paused)
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Cannot remove a transient shared folder from the machine while it is changing the state (machine state: %d)"),
-            mMachineState);
+            tr("Cannot remove a transient shared folder from the machine while it is changing the state (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     ComObjPtr<SharedFolder> sharedFolder;
@@ -2406,6 +2406,6 @@
     if (Global::IsTransient(mMachineState))
         return setError(VBOX_E_INVALID_VM_STATE,
-                        tr("Cannot take a snapshot of the machine while it is changing the state (machine state: %d)"),
-                        mMachineState);
+                        tr("Cannot take a snapshot of the machine while it is changing the state (machine state: %s)"),
+                        Global::stringifyMachineState(mMachineState));
 
     HRESULT rc = S_OK;
@@ -2418,7 +2418,5 @@
     rc = mMachine->COMGETTER(MediumAttachments)(ComSafeArrayAsOutParam(aMediumAttachments));
     if (FAILED(rc))
-        return setError(VBOX_E_INVALID_VM_STATE,
-                        tr("Cannot get medium attachments of the machine"),
-                        mMachineState);
+        return setError(rc, tr("Cannot get medium attachments of the machine"));
 
     ULONG ulMemSize;
@@ -2530,6 +2528,6 @@
     if (Global::IsOnlineOrTransient(mMachineState))
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Cannot discard a snapshot of the running machine (machine state: %d)"),
-            mMachineState);
+            tr("Cannot discard a snapshot of the running machine (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     MachineState_T machineState = MachineState_Null;
@@ -2550,6 +2548,6 @@
     if (Global::IsOnlineOrTransient(mMachineState))
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Cannot discard the current state of the running machine (machine state: %d)"),
-            mMachineState);
+            tr("Cannot discard the current state of the running machine (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     MachineState_T machineState = MachineState_Null;
@@ -2570,6 +2568,6 @@
     if (Global::IsOnlineOrTransient(mMachineState))
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Cannot discard the current snapshot and state of the running machine (machine state: %d)"),
-            mMachineState);
+            tr("Cannot discard the current snapshot and state of the running machine (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     MachineState_T machineState = MachineState_Null;
@@ -4527,6 +4525,6 @@
     if (Global::IsOnlineOrTransient(mMachineState))
         return setError(VBOX_E_INVALID_VM_STATE,
-            tr("Virtual machine is already running or busy (machine state: %d)"),
-            mMachineState);
+            tr("Virtual machine is already running or busy (machine state: %s)"),
+            Global::stringifyMachineState(mMachineState));
 
     HRESULT rc = S_OK;
@@ -4796,5 +4794,5 @@
               mMachineState == MachineState_Restoring ||
               mMachineState == MachineState_Stopping,
-              ("Invalid machine state: %d\n", mMachineState));
+              ("Invalid machine state: %s\n", Global::stringifyMachineState(mMachineState)));
 
     LogRel(("Console::powerDown(): A request to power off the VM has been issued (mMachineState=%d, InUninit=%d)\n",
Index: /trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineImpl.cpp	(revision 23663)
+++ /trunk/src/VBox/Main/MachineImpl.cpp	(revision 23664)
@@ -1888,6 +1888,6 @@
        )
         return setError(VBOX_E_INVALID_VM_STATE,
-                        tr("The machine is not powered off (state is %d)"),
-                        mData->mMachineState);
+                        tr("The machine is not powered off (state is %s)"),
+                        Global::stringifyMachineState(mData->mMachineState));
 
     mUserData.backup();
@@ -2040,6 +2040,6 @@
     if (Global::IsOnlineOrTransient(mData->mMachineState))
         return setError(VBOX_E_INVALID_VM_STATE,
-                        tr("Invalid machine state: %d"),
-                        mData->mMachineState);
+                        tr("Invalid machine state: %s"),
+                        Global::stringifyMachineState(mData->mMachineState));
 
     /* Check for an existing controller. */
@@ -2442,5 +2442,6 @@
     if (Global::IsOnlineOrTransient(mData->mMachineState))
         return setError(VBOX_E_INVALID_VM_STATE,
-                        tr("Invalid machine state: %d"), mData->mMachineState);
+                        tr("Invalid machine state: %s"),
+                        Global::stringifyMachineState(mData->mMachineState));
 
     MediumAttachment *pAttach = findAttachment(mMediaData->mAttachments,
@@ -3033,6 +3034,6 @@
         if (mData->mSession.mState != SessionState_Open)
             return setError(VBOX_E_INVALID_VM_STATE,
-                            tr("Machine session is not open (session state: %d)"),
-                            mData->mSession.mState);
+                            tr("Machine session is not open (session state: %s)"),
+                            Global::stringifyMachineState(mData->mSession.mState));
 
         directControl = mData->mSession.mDirectControl;
@@ -4628,6 +4629,6 @@
                  mData->mMachineState == MachineState_Saved))
                 return setError(VBOX_E_INVALID_VM_STATE,
-                                tr("The machine is not mutable (state is %d)"),
-                                mData->mMachineState);
+                                tr("The machine is not mutable (state is %s)"),
+                                Global::stringifyMachineState(mData->mMachineState));
             break;
         }
@@ -4638,6 +4639,6 @@
                  mData->mMachineState > MachineState_Paused))
                 return setError(VBOX_E_INVALID_VM_STATE,
-                                tr("The machine is not mutable (state is %d)"),
-                                mData->mMachineState);
+                                tr("The machine is not mutable (state is %s)"),
+                                Global::stringifyMachineState(mData->mMachineState));
             break;
         }
