Skip to content

Commit

Permalink
LOG errors from wwivbasic to log file and caller
Browse files Browse the repository at this point in the history
  • Loading branch information
wwiv committed Oct 10, 2024
1 parent 2ba5a93 commit 94bb4b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
27 changes: 14 additions & 13 deletions bbs/basic/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "core/strings.h"
#include "core/textfile.h"
#include "deps/my_basic/core/my_basic.h"
#include "fmt/format.h"
#include "sdk/config.h"

#include <chrono>
Expand Down Expand Up @@ -126,22 +127,22 @@ static void _on_error(struct mb_interpreter_t* s, mb_error_e err, const char* ms
return;
}

std::string errmsg;
if (!func) {
printf("Error:\n Line %d, Col %d\n Code %d, Abort Code %d\n Message: %s.\n", row, col,
err, err == SE_EA_EXTENDED_ABORT ? abort_code - MB_EXTENDED_ABORT : abort_code, msg);
return;
}

if (err == SE_RN_REACHED_TO_WRONG_FUNCTION) {
printf(
errmsg = fmt::sprintf("Error:\n Line %d, Col %d\n Code %d, Abort Code %d\n Message: %s.\n", row, col,
static_cast<int>(err), err == SE_EA_EXTENDED_ABORT ? abort_code - MB_EXTENDED_ABORT : abort_code, msg);
} else if (err == SE_RN_REACHED_TO_WRONG_FUNCTION) {
errmsg = fmt::sprintf(
"Error:\n Line %d, Col %d in Func: %s\n Code %d, Abort Code %d\n Message: %s.\n",
row, col, func, err, abort_code, msg);
return;
row, col, func, static_cast<int>(err), abort_code, msg);
} else {
errmsg = fmt::sprintf(
"Error:\n Line %d, Col %d in File: %s\n Code %d, Abort Code %d\n Message: %s.\n",
row, col, func, static_cast<int>(err), err == SE_EA_EXTENDED_ABORT ? abort_code - MB_EXTENDED_ABORT : abort_code,
msg);
}
printf(
"Error:\n Line %d, Col %d in File: %s\n Code %d, Abort Code %d\n Message: %s.\n",
row, col, func, err, err == SE_EA_EXTENDED_ABORT ? abort_code - MB_EXTENDED_ABORT : abort_code,
msg);
bout.pl(StrCat("|#6", errmsg));
LOG(ERROR) << errmsg;
}

Basic::Basic(common::Input& i, common::Output& o, const sdk::Config& config, common::Context* ctx)
Expand Down
1 change: 1 addition & 0 deletions bbs/basic/wwiv_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "core/log.h"
#include "core/strings.h"
#include "core/cereal_utils.h"
#include "fmt/format.h"
#include <cassert>
#include <optional>
#include <string>
Expand Down

0 comments on commit 94bb4b4

Please sign in to comment.