Skip to content

Commit 243a65f

Browse files
committed
Display exception message when failing process request
1 parent 4e412a7 commit 243a65f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/NFS3Prog.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ int CNFS3Prog::Process(IInputStream *pInStream, IOutputStream *pOutStream, Proce
229229
&CNFS3Prog::ProcedureCOMMIT
230230
};
231231

232-
nfsstat3 stat;
232+
nfsstat3 stat = NULL;
233233

234234
struct tm current;
235235
time_t now;
@@ -253,15 +253,22 @@ int CNFS3Prog::Process(IInputStream *pInStream, IOutputStream *pOutStream, Proce
253253

254254
try {
255255
stat = (this->*pf[pParam->nProc])();
256+
} catch (const std::runtime_error& re) {
257+
m_nResult = PRC_FAIL;
258+
PrintLog("Runtime error: ");
259+
PrintLog(re.what());
260+
} catch (const std::exception& ex) {
261+
m_nResult = PRC_FAIL;
262+
PrintLog("Exception: ");
263+
PrintLog(ex.what());
256264
} catch (...) {
257265
m_nResult = PRC_FAIL;
266+
PrintLog("Unknown failure: Possible memory corruption");
258267
}
259268

260269
PrintLog(" ");
261270

262-
if (m_nResult == PRC_FAIL) { //input data is truncated
263-
PrintLog("fail");
264-
} else {
271+
if (stat != NULL) {
265272
switch (stat) {
266273
case NFS3_OK:
267274
PrintLog("OK");

0 commit comments

Comments
 (0)