Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Exception Handling

Exception Handling

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasedebuggingquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BlackRider
    wrote on last edited by
    #1

    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!

    N 1 Reply Last reply
    0
    • B BlackRider

      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!

      N Offline
      N Offline
      Niklas L
      wrote on last edited by
      #2

      Are you sure dben.Errors[ct].GetDescription() is returning a char* and not some other kind of string like CString or wchar_t*? That's the only thing I can see by just looking at your code.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups