# crash_file

Definition: | crash_file(object filename)
Description: | Specify a file name for holding error diagnostics if Phix must stop your program due to a compile-time or run-time error. Specify 0 to restore default handling, "NULL" (or "NUL" or "/dev/null") to disable the creation of a disk file, or "" to disable diagnostics completely.
pwa/p2js: | Not supported.
Comments: | Normally Phix prints a diagnostic message such as "syntax error" or "divide by zero" on the screen, as well as dumping debugging information into ex.err in the current directory. While the latter is quite predictable at program startup, it can be changed explicitly by chdir() or implicitly via a standard file open dialogue. By calling crash_file() you can control the directory and file name where the debugging information will be written. You could easily write a routine which checks for the presence of any error files at startup and either rename things or generate a new unique name, so that a complete history of any run-time errors is maintained. filename may be empty, i.e. "". In this case no diagnostics or debugging information will be written to either a file or the screen. It might also be "NULL", "NUL" or "/dev/null", in which case diagnostics will be written to the screen, but the ex.err information will be discarded. You can call crash_file() as many times as you like from different parts of your program. The file specified by the last call will be the one used.
Example: |
    crash_file(`\tmp\mybug`)
Implementation: | via :%pCrashFile in builtins\VM\pDiag.e (an autoinclude) - be warned however it is low-level complicated stuff that you do not need to know.
See Also: | abort, crash_message, debugging and profiling