summaryrefslogtreecommitdiff
path: root/compiler/Errors.ml
diff options
context:
space:
mode:
authorEscherichia2024-03-29 13:21:08 +0100
committerEscherichia2024-03-29 13:48:15 +0100
commit786c54c01ea98580374638c0ed92d19dfae19b1f (patch)
tree4ad9010c76553797420bcaa2976ed02c216a2757 /compiler/Errors.ml
parentbd89156cbdcb047ed9a6c557e9873dd5724c391f (diff)
added file and line arg to craise and cassert
Diffstat (limited to '')
-rw-r--r--compiler/Errors.ml38
1 files changed, 19 insertions, 19 deletions
diff --git a/compiler/Errors.ml b/compiler/Errors.ml
index 68073ef7..bfdf5796 100644
--- a/compiler/Errors.ml
+++ b/compiler/Errors.ml
@@ -13,43 +13,43 @@ exception CFailure of string
let error_list : (Meta.meta option * string) list ref = ref []
-let push_error (meta : Meta.meta option) (msg : string) =
- error_list := (meta, msg) :: !error_list
+let push_error (file : string) (line : int) (meta : Meta.meta option) (msg : string) =
+ error_list := (meta, msg ^ "\n In file:" ^ file ^ "\n Line:" ^ string_of_int line) :: !error_list
-let save_error ?(b : bool = true) (meta : Meta.meta option) (msg : string) =
- push_error meta msg;
+let save_error (file : string) (line : int) ?(b : bool = true) (meta : Meta.meta option) (msg : string) =
+ push_error file line meta msg;
match meta with
| Some m ->
if !Config.fail_hard && b then
- raise (Failure (format_error_message m msg))
+ raise (Failure (format_error_message m (msg ^ "\n In file:" ^ file ^ "\n Line:" ^ string_of_int line)))
| None -> if !Config.fail_hard && b then raise (Failure msg)
-let craise_opt_meta (meta : Meta.meta option) (msg : string) =
+let craise_opt_meta (file : string) (line : int) (meta : Meta.meta option) (msg : string) =
match meta with
| Some m ->
- if !Config.fail_hard then raise (Failure (format_error_message m msg))
+ if !Config.fail_hard then raise (Failure (format_error_message m (msg ^ "\n In file:" ^ file ^ "\n Line:" ^ string_of_int line)))
else
- let () = push_error (Some m) msg in
+ let () = push_error file line (Some m) msg in
raise (CFailure msg)
| None ->
- if !Config.fail_hard then raise (Failure msg)
+ if !Config.fail_hard then raise (Failure (msg ^ "\n In file:" ^ file ^ "\n Line:" ^ string_of_int line))
else
- let () = push_error None msg in
+ let () = push_error file line None msg in
raise (CFailure msg)
-let craise (meta : Meta.meta) (msg : string) = craise_opt_meta (Some meta) msg
+let craise (file : string) (line : int) (meta : Meta.meta) (msg : string) = craise_opt_meta file line (Some meta) msg
-let cassert_opt_meta (b : bool) (meta : Meta.meta option) (msg : string) =
- if not b then craise_opt_meta meta msg
+let cassert_opt_meta (file : string) (line : int) (b : bool) (meta : Meta.meta option) (msg : string) =
+ if not b then craise_opt_meta file line meta msg
-let cassert (b : bool) (meta : Meta.meta) (msg : string) =
- cassert_opt_meta b (Some meta) msg
+let cassert (file : string) (line : int) (b : bool) (meta : Meta.meta) (msg : string) =
+ cassert_opt_meta file line b (Some meta) msg
-let sanity_check b meta = cassert b meta "Internal error, please file an issue"
+let sanity_check (file : string) (line : int) b meta = cassert file line b meta "Internal error, please file an issue"
-let sanity_check_opt_meta b meta =
- cassert_opt_meta b meta "Internal error, please file an issue"
+let sanity_check_opt_meta (file : string) (line : int) b meta =
+ cassert_opt_meta file line b meta "Internal error, please file an issue"
-let internal_error meta = craise meta "Internal error, please report an issue"
+let internal_error (file : string) (line : int) meta = craise file line meta "Internal error, please report an issue"
let exec_raise = craise
let exec_assert = cassert