SNAP Library 3.0, User Reference  2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bd.cpp File Reference

Go to the source code of this file.

Functions

int _matherr (struct _exception *e)
 
void WrNotify (const char *CaptionCStr, const char *NotifyCStr)
 
void SaveToErrLog (const char *MsgCStr)
 
void ExeStop (const char *MsgCStr, const char *ReasonCStr, const char *CondCStr, const char *FNm, const int &LnN)
 

Function Documentation

int _matherr ( struct _exception *  e)

Definition at line 33 of file bd.cpp.

33  {
34  e->retval=0;
35  return 1;
36 }
void ExeStop ( const char *  MsgCStr,
const char *  ReasonCStr,
const char *  CondCStr,
const char *  FNm,
const int &  LnN 
)

Definition at line 88 of file bd.cpp.

90  {
91  char ReasonMsgCStr[1000];
92 
93 #if SW_TRACE
94  PrintBacktrace();
95  Crash();
96 #endif
97 
98  // construct reason message
99  if (ReasonCStr==NULL){ReasonMsgCStr[0]=0;}
100  else {sprintf(ReasonMsgCStr, " [Reason:'%s']", ReasonCStr);}
101  // construct full message
102  char FullMsgCStr[1000];
103  if (MsgCStr==NULL){
104  if (CondCStr==NULL){
105  sprintf(FullMsgCStr, "Execution stopped%s!", ReasonMsgCStr);
106  } else {
107  sprintf(FullMsgCStr, "Execution stopped: %s%s, file %s, line %d",
108  CondCStr, ReasonMsgCStr, FNm, LnN);
109  }
110  } else {
111  if (CondCStr==NULL){
112  sprintf(FullMsgCStr, "%s\nExecution stopped!", MsgCStr);
113  } else {
114  sprintf(FullMsgCStr, "Message: %s%s\nExecution stopped: %s, file %s, line %d",
115  MsgCStr, ReasonMsgCStr, CondCStr, FNm, LnN);
116  }
117  }
118  // report full message to log file
119  SaveToErrLog(FullMsgCStr);
120 
121 #if defined(SW_NOABORT)
122  TExcept::Throw(FullMsgCStr);
123 #endif
124 
125  // report to screen & stop execution
126  bool Continue=false;
127  // call handler
129  Continue=!((*TOnExeStop::GetOnExeStopF())(FullMsgCStr));}
130  if (!Continue){
131  ErrNotify(FullMsgCStr);
132 #ifdef GLib_WIN32
133  abort();
134  //ExitProcess(1);
135 #else
136  exit(1);
137 #endif
138  }
139 }
void ErrNotify(const char *NotifyCStr)
Definition: bd.h:74
static void Throw(const TStr &MsgStr)
Definition: ut.h:187
void SaveToErrLog(const char *MsgCStr)
Definition: bd.cpp:49
static bool IsOnExeStopF()
Definition: bd.h:229
static TOnExeStopF GetOnExeStopF()
Definition: bd.h:231
void SaveToErrLog ( const char *  MsgCStr)

Definition at line 49 of file bd.cpp.

49  {
50  int MxFNmLen=1000;
51  char* FNm=new char[MxFNmLen]; if (FNm==NULL){return;}
52  int FNmLen=GetModuleFileName(NULL, FNm, MxFNmLen); if (FNmLen==0){return;}
53  FNm[FNmLen++]='.'; FNm[FNmLen++]='E'; FNm[FNmLen++]='r'; FNm[FNmLen++]='r';
54  FNm[FNmLen++]=char(0);
55  time_t Time=time(NULL);
56  FILE* fOut=fopen(FNm, "a+b"); if (fOut==NULL){return;}
57  fprintf(fOut, "--------\r\n%s\r\n%s%s\r\n--------\r\n",
58  FNm, ctime(&Time), MsgCStr);
59  fclose(fOut);
60  delete[] FNm;
61 }
void WrNotify ( const char *  CaptionCStr,
const char *  NotifyCStr 
)

Definition at line 41 of file bd.cpp.

41  {
42 #if defined(__CONSOLE__) || defined(_CONSOLE)
43  printf("*** %s: %s\n", CaptionCStr, NotifyCStr);
44 #else
45  MessageBox(NULL, NotifyCStr, CaptionCStr, MB_OK);
46 #endif
47 }