[better error interface in the library, use this interface. Burrgui now has message boxes on errors
Andreas Röver <roever@users.sourceforge.net>**20050623173111] {
hunk ./src/burrTxt.cpp 147
-  assm->createMatrix(&p, 0);
+
+  switch (assm->createMatrix(&p, 0)) {
+  case assm_0_frontend_0_c::ERR_TOO_MANY_UNITS:
+    printf("%i units too many for the result shape\n", assm->getErrorsParam());
+    return 0;
+  case assm_0_frontend_0_c::ERR_TOO_FEW_UNITS:
+    printf("%i units too few for the result shape\n", assm->getErrorsParam());
+    return 0;
+  case assm_0_frontend_0_c::ERR_CAN_NOT_PLACE:
+    printf("Piece %i can be place nowhere in the result shape\n", assm->getErrorsParam());
+    return 0;
+  }
hunk ./src/burrTxt.cpp 164
-  }
-
-  if (assm->errors()) {
-    cout << assm->errors() << endl;
-    delete assm;
-    return 0;
hunk ./src/gui/AssemblyCallbacks.cpp 48
-    assm->createMatrix(p->puzzle, p->prob);
-    if (assm->errors()) {
-      printf(" error, %s\n", assm->errors());
+
+    p->errState = assm->createMatrix(p->puzzle, p->prob);
+    if (p->errState != assm_0_frontend_0_c::ERR_NONE) {
+
+      p->errParam = assm->getErrorsParam();
+
+      p->action = assemblerThread::ACT_ERROR;
hunk ./src/gui/AssemblyCallbacks.h 39
+  assembler_c::errState errState;
+  int errParam;
+
hunk ./src/gui/AssemblyCallbacks.h 65
-    ACT_FINISHED
+    ACT_FINISHED,
+    ACT_ERROR
hunk ./src/gui/AssemblyCallbacks.h 80
+  assembler_c::errState getErrorState(void) { return errState; }
+  int getErrorParam(void) { return errParam; }
+
hunk ./src/gui/MainWindow.cpp 907
+
+    } else if (assmThread->currentAction() == assemblerThread::ACT_ERROR) {
+
+      switch(assmThread->getErrorState()) {
+      case assembler_c::ERR_TOO_MANY_UNITS:
+        fl_message("Pieces contain %i units too many", assmThread->getErrorParam());
+        break;
+      case assembler_c::ERR_TOO_FEW_UNITS:
+        fl_message("Pieces contain %i units less than required", assmThread->getErrorParam());
+        break;
+      case assembler_c::ERR_CAN_NOT_PLACE:
+        fl_message("Piece %i can be placed onwhere within the result", assmThread->getErrorParam());
+        break;
+      }
+
+      delete assmThread;
+      assmThread = 0;
hunk ./src/lib/assembler.h 54
+  typedef enum {
+    ERR_NONE,
+    ERR_TOO_MANY_UNITS,
+    ERR_TOO_FEW_UNITS,
+    ERR_CAN_NOT_PLACE
+  } errState;
+
hunk ./src/lib/assembler.h 69
-  virtual const char * errors(void) { return 0; }
+  virtual int getErrorsParam(void) { return 0; }
hunk ./src/lib/assembler_0.cpp 145
-void assembler_0_c::createMatrix(const puzzle_c * puz, unsigned int prob) {
+assembler_0_c::errState assembler_0_c::createMatrix(const puzzle_c * puz, unsigned int prob) {
hunk ./src/lib/assembler_0.cpp 168
-    errorsState = 1;
+    errorsState = ERR_TOO_MANY_UNITS;
hunk ./src/lib/assembler_0.cpp 170
-    return;
+    return errorsState;
hunk ./src/lib/assembler_0.cpp 174
-    errorsState = 2;
+    errorsState = ERR_TOO_FEW_UNITS;
hunk ./src/lib/assembler_0.cpp 176
-    return;
+    return errorsState;
hunk ./src/lib/assembler_0.cpp 186
-    errorsState = 3;
+    errorsState = ERR_CAN_NOT_PLACE;
hunk ./src/lib/assembler_0.cpp 188
-    return;
+    return errorsState;
hunk ./src/lib/assembler_0.cpp 223
-  errorsState = 0;
+
+  errorsState = ERR_NONE;
+  return errorsState;
hunk ./src/lib/assembler_0.cpp 828
-  if (errorsState == 0) {
+  if (errorsState == ERR_NONE) {
hunk ./src/lib/assembler_0.cpp 961
-}
-
-
-const char * assembler_0_c::errors(void) {
-
-  static char tmp[500];
-
-  switch (errorsState) {
-  case 0: return 0;
-  case 1:
-    snprintf(tmp, 500, "There are %i more cubes than there is space in result!", errorsParam);
-    return tmp;
-  case 2:
-    snprintf(tmp, 500, "There are %i less cubes than we need in result space!", errorsParam);
-    return tmp;
-  case 3:
-    snprintf(tmp, 500, "There is no room for piece %i in the solution shape!", errorsParam);
-    return tmp;
-  }
-
-  return 0;
hunk ./src/lib/assembler_0.h 186
-  int errorsState;
+  errState errorsState;
hunk ./src/lib/assembler_0.h 261
-  void createMatrix(const puzzle_c * puz, unsigned int problemNum);
+
+  errState createMatrix(const puzzle_c * puz, unsigned int problemNum);
hunk ./src/lib/assembler_0.h 272
-  const char * errors(void);
+  int getErrorsParam(void) { return errorsParam; }
+
hunk ./src/lib/burrgrower.cpp 34
-  assm->createMatrix(p, 0);
+  if (assm->createMatrix(p, 0) == assm_0_frontend_0_c::ERR_NONE) {
hunk ./src/lib/burrgrower.cpp 36
-  solutions = 0;
-
-  if (!assm->errors()) {
+    solutions = 0;
hunk ./src/tester.cpp 235
-  printf("start reduce\n");
-  assm->reduce();
-  printf("finished reduce\n");
hunk ./src/tester.cpp 236
-  if (assm->errors()) {
-    printf("%s\n", assm->errors());
+  if (assm->createMatrix(&p, 0) != assm_0_frontend_0_c::ERR_NONE) {
+    printf("errors\n");
hunk ./src/tester.cpp 241
+
+  printf("start reduce\n");
+  assm->reduce();
+  printf("finished reduce\n");
}
