log exceptions that occur to a local file
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
shf
|
shf
|
||||||
shf-tests
|
shf-tests
|
||||||
|
exceptions.log
|
||||||
|
|||||||
@@ -229,9 +229,7 @@ struct
|
|||||||
end
|
end
|
||||||
|
|
||||||
fun yank (shellState: t, str) =
|
fun yank (shellState: t, str) =
|
||||||
( Glfw.setClipboardString (#window shellState, str);
|
(Glfw.setClipboardString (#window shellState, str); shellState)
|
||||||
shellState
|
|
||||||
)
|
|
||||||
|
|
||||||
fun consumeDrawEvent (shellState, msg) =
|
fun consumeDrawEvent (shellState, msg) =
|
||||||
let
|
let
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ structure UpdateThread =
|
|||||||
struct
|
struct
|
||||||
open CML
|
open CML
|
||||||
open MailboxType
|
open MailboxType
|
||||||
|
open InputMsg
|
||||||
|
|
||||||
fun sendMsg (msg, drawMailbox) =
|
fun sendMsg (msg, drawMailbox) =
|
||||||
case msg of DRAW msg => Mailbox.send (drawMailbox, msg)
|
case msg of DRAW msg => Mailbox.send (drawMailbox, msg)
|
||||||
@@ -14,21 +15,46 @@ struct
|
|||||||
end
|
end
|
||||||
| [] => ()
|
| [] => ()
|
||||||
|
|
||||||
|
val textCommands = ref ""
|
||||||
|
|
||||||
|
fun addTextCommand inputMsg =
|
||||||
|
case inputMsg of
|
||||||
|
CHAR_EVENT chr =>
|
||||||
|
let
|
||||||
|
val chr = CharVector.fromList [chr]
|
||||||
|
val newInput = !textCommands ^ chr
|
||||||
|
in
|
||||||
|
textCommands := newInput
|
||||||
|
end
|
||||||
|
| _ => ()
|
||||||
|
|
||||||
|
fun handleException e =
|
||||||
|
let
|
||||||
|
(* print stack trace for debugging purposes,
|
||||||
|
* and then raise another exception to exit the program *)
|
||||||
|
val stackTrace = MLton.Exn.history e
|
||||||
|
val stackTrace = String.concatWith "\n" stackTrace
|
||||||
|
val () = print "ERROR:\n"
|
||||||
|
val () = print (stackTrace ^ "\n\n")
|
||||||
|
|
||||||
|
val history = !textCommands ^ "\n\n"
|
||||||
|
val () = print ("HISTORY: " ^ history)
|
||||||
|
|
||||||
|
val textOutput = stackTrace ^ "\n" ^ history
|
||||||
|
|
||||||
|
val io = TextIO.openAppend "exceptions.log"
|
||||||
|
val () = TextIO.output (io, textOutput)
|
||||||
|
val () = TextIO.closeOut io
|
||||||
|
in
|
||||||
|
raise Empty
|
||||||
|
end
|
||||||
|
|
||||||
fun loop (app: AppType.app_type, inputMailbox, drawMailbox) =
|
fun loop (app: AppType.app_type, inputMailbox, drawMailbox) =
|
||||||
let
|
let
|
||||||
val inputMsg = Mailbox.recv inputMailbox
|
val inputMsg = Mailbox.recv inputMailbox
|
||||||
val app =
|
val () = addTextCommand inputMsg
|
||||||
AppUpdate.update (app, inputMsg)
|
|
||||||
handle e =>
|
val app = AppUpdate.update (app, inputMsg) handle e => handleException e
|
||||||
let
|
|
||||||
(* print stack trace for debugging purposes,
|
|
||||||
* and then raise another exception to exit the program *)
|
|
||||||
val stackTrace = MLton.Exn.history e
|
|
||||||
val stackTrace = String.concatWith "\n" stackTrace
|
|
||||||
val () = print (stackTrace ^ "\n")
|
|
||||||
in
|
|
||||||
raise Empty
|
|
||||||
end
|
|
||||||
|
|
||||||
val () = sendMsgs (#msgs app, drawMailbox)
|
val () = sendMsgs (#msgs app, drawMailbox)
|
||||||
in
|
in
|
||||||
|
|||||||
Reference in New Issue
Block a user