catch exception as const ref
This commit is contained in:
parent
498d1f17aa
commit
ecffde3635
12
ml.cpp
12
ml.cpp
|
|
@ -1953,7 +1953,9 @@ MlValue thread_create(std::vector<MlValue> args, MlEnvironment &env) {
|
|||
try {
|
||||
for (size_t i = 0; i < args.size(); i++)
|
||||
MlValue acc = args[i].eval(env);
|
||||
} catch (std::exception &e) {
|
||||
} catch (const MlError &e) {
|
||||
std::cerr << "thread_create exception: " << e.description() << std::endl;
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << "thread_create exception: " << e.what() << std::endl;
|
||||
throw e;
|
||||
}
|
||||
|
|
@ -2024,7 +2026,7 @@ MlValue try_block(std::vector<MlValue> args, MlEnvironment &env) {
|
|||
cs_posisition = MlPerfMon::instance().get_callstack_position();
|
||||
value = args[0].eval(env);
|
||||
// catch block
|
||||
} catch (std::exception &e) {
|
||||
} catch (const std::exception &e) {
|
||||
MlPerfMon::instance().restore_callstack_position(cs_posisition);
|
||||
env.set("ml-exception", MlValue::string(e.what()));
|
||||
value = args[1].eval(env);
|
||||
|
|
@ -2251,10 +2253,10 @@ void repl(MlEnvironment &env) {
|
|||
tmp = run(input, env);
|
||||
std::cout << " => " << tmp.debug() << std::endl;
|
||||
code += input + "\n";
|
||||
} catch (MlError &e) {
|
||||
} catch (const MlError &e) {
|
||||
std::cerr << e.description() << std::endl;
|
||||
MlPerfMon::instance().clear_callstack();
|
||||
} catch (std::exception &e) {
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -2335,7 +2337,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
return 0;
|
||||
|
||||
} catch (MlError &e) {
|
||||
} catch (const MlError &e) {
|
||||
std::cerr << e.description() << std::endl;
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << MlPerfMon::instance().callstack() << e.what() << std::endl;
|
||||
|
|
|
|||
Loading…
Reference in New Issue