tool/CommandFoeRead.cpp
changeset 1336 e27b37e80a99
parent 1335 09c6fce1ae45
child 1357 b065f49113f4
--- a/tool/CommandFoeRead.cpp	Mon Jan 26 13:01:58 2009 +0000
+++ b/tool/CommandFoeRead.cpp	Mon Jan 26 13:09:27 2009 +0000
@@ -9,6 +9,7 @@
 using namespace std;
 
 #include "CommandFoeRead.h"
+#include "foe.h"
 
 /*****************************************************************************/
 
@@ -82,7 +83,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