Exception Handling
-
I'm TRYING to catch database exception and output that to an error file. Here's the CATCH code : catch (CdbException) { FILE* errorfile; errorfile=fopen("c:\\cristi\\error.err","a"); fprintf(errorfile,"v,dmlkvmdsv"); for (long ct = 0; ct < dben.Errors.GetCount(); ct++) { fprintf(errorfile,_T("\t Error #%ld: #%ld -- %s\n"), ct, DBERR(dben.Errors[ct].GetNumber()), dben.Errors[ct].GetDescription()); } fclose(errorfile); return; } This code just won't work. I get nothing in the file. Nothing. It's not even accessed. This other code below that prints the error data to the screen works. catch (CdbException) { for (long ct = 0; ct < dben.Errors.GetCount(); ct++) { printf(_T("\t Error #%ld: #%ld -- %s\n"), ct, DBERR(dben.Errors[ct].GetNumber()), dben.Errors[ct].GetDescription()); } return; } Now. ---> In both cases I get this error message: Debug Assertion Failed! Program: ...program File:dbgheap.c Line:1044 Expression: _CrtIsValidHeapPointer(pUserData) I belive the second code works because of the printf lack of buffering so that the error message that I display at the console displays faster than the debug assertion failed error. Anyway, this isn't the problem. The problem is why do I get that error message. What happend over there. Anyone encountered this problem before ? Thank you!
-
I'm TRYING to catch database exception and output that to an error file. Here's the CATCH code : catch (CdbException) { FILE* errorfile; errorfile=fopen("c:\\cristi\\error.err","a"); fprintf(errorfile,"v,dmlkvmdsv"); for (long ct = 0; ct < dben.Errors.GetCount(); ct++) { fprintf(errorfile,_T("\t Error #%ld: #%ld -- %s\n"), ct, DBERR(dben.Errors[ct].GetNumber()), dben.Errors[ct].GetDescription()); } fclose(errorfile); return; } This code just won't work. I get nothing in the file. Nothing. It's not even accessed. This other code below that prints the error data to the screen works. catch (CdbException) { for (long ct = 0; ct < dben.Errors.GetCount(); ct++) { printf(_T("\t Error #%ld: #%ld -- %s\n"), ct, DBERR(dben.Errors[ct].GetNumber()), dben.Errors[ct].GetDescription()); } return; } Now. ---> In both cases I get this error message: Debug Assertion Failed! Program: ...program File:dbgheap.c Line:1044 Expression: _CrtIsValidHeapPointer(pUserData) I belive the second code works because of the printf lack of buffering so that the error message that I display at the console displays faster than the debug assertion failed error. Anyway, this isn't the problem. The problem is why do I get that error message. What happend over there. Anyone encountered this problem before ? Thank you!