|
@@ -259,24 +259,30 @@ int Main() {
|
|
|
}
|
|
|
|
|
|
int main() {
|
|
|
- std::string base_path = getExedir(1);
|
|
|
- if (base_path.empty()) {
|
|
|
- printf_stderr(0, "aFunlang init error.");
|
|
|
- aFunExitReal(EXIT_FAILURE);
|
|
|
- }
|
|
|
+ int exit_code = 0;
|
|
|
+ try {
|
|
|
+ std::string base_path = getExedir(1);
|
|
|
+ if (base_path.empty()) {
|
|
|
+ printf_stderr(0, "aFunlang init error.");
|
|
|
+ aFunExitReal(EXIT_FAILURE);
|
|
|
+ }
|
|
|
|
|
|
- aFuntool::LogFactory factor {};
|
|
|
- aFuncore::InitInfo info = {.base_dir=base_path,
|
|
|
- .factor=factor,
|
|
|
- .log_asyn=true,
|
|
|
- .level=log_debug,
|
|
|
- };
|
|
|
+ aFuntool::LogFactory factor{};
|
|
|
+ aFuncore::InitInfo info = {.base_dir=base_path,
|
|
|
+ .factor=factor,
|
|
|
+ .log_asyn=true,
|
|
|
+ .level=log_debug,
|
|
|
+ };
|
|
|
|
|
|
- if (!aFunCoreInit(&info)) {
|
|
|
- printf_stderr(0, "aFunlang init error.");
|
|
|
- aFunExitReal(EXIT_FAILURE);
|
|
|
- }
|
|
|
+ if (!aFunCoreInit(&info)) {
|
|
|
+ printf_stderr(0, "aFunlang init error.");
|
|
|
+ aFunExitReal(EXIT_FAILURE);
|
|
|
+ }
|
|
|
|
|
|
- int exit_code = Main();
|
|
|
+ exit_code = Main();
|
|
|
+ aFunExit(exit_code);
|
|
|
+ } catch (aFuntool::Exit &e) {
|
|
|
+ exit_code = e.getExitCode();
|
|
|
+ }
|
|
|
aFunExitReal(exit_code);
|
|
|
}
|