| 165 | }; |
| 166 | |
| 167 | void write_stack_trace(const char *stack_trace) { |
| 168 | kinc_log(KINC_LOG_LEVEL_INFO, "Trace: %s", stack_trace); |
| 169 | |
| 170 | #ifdef KORE_WINDOWS |
| 171 | FILE *file = fopen("stderr.txt", stderr_created ? "a" : "w"); |
| 172 | if (file == nullptr) { // Running from protected path |
| 173 | strcpy(temp_string, kinc_internal_save_path()); |
| 174 | strcat(temp_string, "\\stderr.txt"); |
| 175 | file = fopen(temp_string, stderr_created ? "a" : "w"); |
| 176 | } |
| 177 | if (file != nullptr) { |
| 178 | stderr_created = true; |
| 179 | fwrite(stack_trace, 1, strlen(stack_trace), file); |
| 180 | fwrite("\n", 1, 1, file); |
| 181 | fclose(file); |
| 182 | } |
| 183 | #endif |
| 184 | } |
| 185 | |
| 186 | void handle_exception(TryCatch *try_catch) { |
| 187 | MaybeLocal<Value> trace = try_catch->StackTrace(isolate->GetCurrentContext()); |