Summary: Calling `Exn.backtrace` doesn't give us the current backtrace, only the one of the latest exception raised. Change the logic of toplevel exception catching to print the right backtrace. Also, do not use `Format` to print from `Config` as `Logging` may have messed with it already. Finally, throw in some colours! Reviewed By: jberdine Differential Revision: D5764825 fbshipit-source-id: cd51688master
parent
6ab174f0c3
commit
b5ff17825f
@ -1,23 +0,0 @@
|
||||
(*
|
||||
* Copyright (c) 2017 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
let erase_backtrace exn =
|
||||
match exn with
|
||||
| Logging.InferUserError (msg, _)
|
||||
-> Logging.InferUserError (msg, "")
|
||||
| Logging.InferExternalError (msg, _)
|
||||
-> Logging.InferExternalError (msg, "")
|
||||
| Logging.InferInternalError (msg, _)
|
||||
-> Logging.InferInternalError (msg, "")
|
||||
| _
|
||||
-> exn
|
||||
|
||||
let assert_raises ?msg exn f =
|
||||
OUnit2.assert_raises ?msg (erase_backtrace exn) (fun () ->
|
||||
try f ()
|
||||
with exn -> raise (erase_backtrace exn) )
|
@ -1,14 +0,0 @@
|
||||
(*
|
||||
* Copyright (c) 2017 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
val assert_raises : ?msg:string -> exn -> (unit -> 'a) -> unit
|
||||
(** OUnit2.assert_raises checks that a function raises some exception that's exactly the same as a
|
||||
reference exception, but some of our internal exceptions contain verbose and flaky data, eg
|
||||
backtraces. This will normalize such known exceptions by erasing their verbose data. Use this if
|
||||
you're suffering from OUnit2.assert_raises. *)
|
Loading…
Reference in new issue