tool/CommandFoeRead.cpp
branch1.4-foe
changeset 1708 fae3a1759126
parent 1707 11ec009e145d
--- a/tool/CommandFoeRead.cpp	Mon Jan 19 10:18:41 2009 +0000
+++ b/tool/CommandFoeRead.cpp	Mon Jan 19 12:36:18 2009 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
  *
- * $Id:$
+ * $Id$
  *
  ****************************************************************************/
 
@@ -10,6 +10,7 @@
 
 #include "CommandFoeRead.h"
 #include "byteorder.h"
+#include "foe.h"
 
 /*****************************************************************************/
 
@@ -83,7 +84,19 @@
 		m.readFoe(&data);
 	} catch (MasterDeviceException &e) {
         delete [] data.buffer;
-		throw e;
+        if (data.result) {
+            if (data.result == FOE_OPCODE_ERROR) {
+                err << "FoE read aborted with error code 0x"
+                    << setw(8) << setfill('0') << hex << data.error_code
+                    << ": " << errorText(data.error_code);
+            } else {
+                err << "Failed to write via FoE: "
+                    << resultText(data.result);
+            }
+            throwCommandException(err);
+        } else {
+            throw e;
+        }
 	}
 
     // TODO --output-file