SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
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 35 of file bd.cpp.

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

Definition at line 90 of file bd.cpp.

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

Definition at line 51 of file bd.cpp.

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

Definition at line 43 of file bd.cpp.

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