Skip to content

Commit

Permalink
Merge pull request #1021 from tleedjarv/soverfl-msg
Browse files Browse the repository at this point in the history
Add a specific error message for the Stack_overflow exception
  • Loading branch information
gdt authored Apr 23, 2024
2 parents ba557e7 + 3d0bb14 commit fba6250
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/uicommon.ml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ let exn2string e =
Unix.EUNKNOWNERR n -> Format.sprintf " (code %d)" n
| _ -> "")
(Printexc.get_backtrace ())
| Stack_overflow ->
"Stack overflow. This could indicate a programming error.\n\n\
Technical information in case you need to report a bug:\n"
^ (Printexc.get_backtrace ())
| Invalid_argument s ->
Printf.sprintf "Invalid argument: %s\n%s" s (Printexc.get_backtrace ())
| other -> Printf.sprintf "Uncaught exception %s\n%s"
Expand Down
8 changes: 8 additions & 0 deletions src/uigtk3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,13 @@ let fatalError ?(quit=false) message =

let fatalErrorHandler = ref (fatalError ~quit:true)

let stackOverflowNoQuitMsg () =
"Stack overflow. This could indicate a programming error.\n\
You should be able to continue without having to quit \
the application but the error may repeat.\n\n\
Technical information in case you need to report a bug:\n"
^ (Printexc.get_backtrace ())

(* ------ *)

let getFirstRoot () =
Expand Down Expand Up @@ -4468,6 +4475,7 @@ let start _ =
GtkSignal.user_handler :=
(function
| Util.Transient s | Util.Fatal s -> !fatalErrorHandler s
| Stack_overflow -> !fatalErrorHandler (stackOverflowNoQuitMsg ());
| exn -> !fatalErrorHandler (Uicommon.exn2string exn));
(* Ask the Remote module to call us back at regular intervals during
Expand Down

0 comments on commit fba6250

Please sign in to comment.