{= include "templates.shared.util.convert_to_valid_node_name"; include "templates.shared.error_handling.util.decode_salang_string_to_html"; debug_message("error.cfv START\n"); # ------------------------------------- # get task_info (for debug output only) # ------------------------------------- # if (node_exists("volatile.task_info")) then (delete_node("volatile.task_info");); # get_task_info("volatile.task_info"); # debug_message("error.cfv - task_info node:\n" . node_as_string("volatile.task_info") . "\n\n\n"); # ---------------------------- # subroutine create_error_id() # ---------------------------- subroutine(create_error_id, ( string error_id = "error_" . now(); # In case that the error_id already exists extend the id with the letter "a" while (node_exists("ReportCache." . error_id)) ( error_id .= "a"; ); error_id; )); # ---------------------------------- # subroutine encode_to_salang_string # ---------------------------------- subroutine(encode_to_salang_string(string the_string), ( the_string = replace_all(the_string, "\t", "__TAB__"); the_string = replace_all(the_string, "&", "__AMPERSAND__"); the_string = replace_all(the_string, "$", "__DOLLAR__"); the_string = replace_all(the_string, "{=", "__CURVED_BRACE_LEFT__"); the_string = replace_all(the_string, "=}", "__CURVED_BRACE_RIGHT__"); the_string = replace_all(the_string, "(", "__BRACE_LEFT__"); the_string = replace_all(the_string, ")", "__BRACE_RIGHT__"); the_string = replace_all(the_string, '"', "__DOUBLE_QUOTE__"); the_string = replace_all(the_string, "\n", "__LINE_FEED__"); the_string = replace_all(the_string, '\r', ""); the_string = replace_all(the_string, "\\", ""); the_string; )); # ----------- # Error types # ----------- # error.cfv is used in three different ways # 1. error_standard - error is displayed directly in the calling template # 2. error_callback - the calling client is informed that an error occurd # 3. error_xmlhttp_callback - same as above but via xmlhttp call # 4. error_window - the calling client requests a new error window, it will display an existing error message # 5. error_progress_task - error is displayed directly in the calling template, though the error is called from Salang # in case that a process is terminated while progress is shown, i.e. if the system crashes. bool error_standard = false; bool error_callback = false; bool error_xmlhttp_callback = false; bool error_window = false; bool error_progress_task = false; if (node_exists("volatile.error_callback")) then ( error_callback = true; ) else if (node_exists("volatile.error_xmlhttp_callback")) then ( error_xmlhttp_callback = true; ) else if (node_exists("volatile.error_window")) then ( error_window = true; ) else if (node_exists("volatile.error_progress_task")) then ( error_progress_task = true; ) else ( error_standard = true; ); debug_message("error_standard: " . error_standard . "\n"); debug_message("error_callback: " . error_callback . "\n"); debug_message("error_xmlhttp_callback: " . error_xmlhttp_callback . "\n"); debug_message("error_window: " . error_window . "\n"); debug_message("error_progress_task: " . error_progress_task . "\n"); # --------------- # Handle error_id # --------------- string error_id; # error_id is the node_name as which the error message is saved in ReportCache if (!error_window) then ( if (error_progress_task) then ( # error is generated by Salang and volatile.error_message does not exist, set it now! volatile.error_message = lang_admin.messages.background_process_terminated; volatile.error_traceback = "This error has been called from Salang when a process has been terminated during progress display, i.e. when the system crashed."; # Don't translate, used for bug report only! ); string error_id; # Save the error message in ReportCache to # a.) display the error message through a callback via error_window # b.) to report the error to Sawmill # Note, we don't save the error message in TemporaryFiles because this folder gets cleaned very frequently! error_id = create_error_id(); "ReportCache." . error_id . ".error_message" = encode_to_salang_string(node_value("volatile.error_message")); if (node_exists("volatile.error_traceback")) then ( "ReportCache." . error_id . ".error_traceback" = encode_to_salang_string(node_value("volatile.error_traceback")); ) else ( "ReportCache." . error_id . ".error_traceback" = "No traceback available."; ); save_node("ReportCache." . error_id); ) else ( error_id = volatile.error_id; # error_id is send from client! ); # ====== # output # ====== if (!error_xmlhttp_callback) then ( templates.shared.doctype; '\n'; '
\n'; '' . expand(lang_stats.error_handling.report_it_info) . '
\n'; '