{{[banner_logo, "This file is generated by cppbind on 06/23/2021-14:46.\nPlease do not change it manually."]|make_doxygen_comment}}

{% set file_rel_name = path.relpath(file_name, vars.helpers_dir) -%}
package {{vars.helpers_package_prefix}}

import kotlin.system.exitProcess

public class ExceptionHandler {
    companion object {
        private var uncaughtExceptionHandler = {errMsg: String -> defaultHandler(errMsg)}

        fun defaultHandler(errMsg: String) {
            println("Uncaught exception is found: ${errMsg}")
            exitProcess(1)
        }

        @JvmStatic
        fun handleUncaughtException(errMsg: String) {
            uncaughtExceptionHandler(errMsg)
        }

        fun setUncaughtExceptionHandler(handler: (String) -> Unit) {
            uncaughtExceptionHandler = {errMsg: String -> handler(errMsg)}
        }

        fun unsetUncaughtExceptionHandler() {
            uncaughtExceptionHandler = {errMsg: String -> defaultHandler(errMsg)}
        }
    }
}
