about summary refs log tree commit diff
path: root/src/error
diff options
context:
space:
mode:
authorMalte Voos <git@mal.tc>2024-07-08 22:01:42 +0200
committerMalte Voos <git@mal.tc>2024-07-08 22:01:42 +0200
commit97f84ccace4e634b4e02178a702818e69292dc9f (patch)
tree9cef95c62e3fa078db256c7fe657732fecef40a8 /src/error
parent57de10d8728f51942f676b68f1f3ea29d9b78e6e (diff)
downloadtoytt-97f84ccace4e634b4e02178a702818e69292dc9f.tar.gz
toytt-97f84ccace4e634b4e02178a702818e69292dc9f.zip
implement top-level definitions
Diffstat (limited to 'src/error')
-rw-r--r--src/error/Error.ml16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/error/Error.ml b/src/error/Error.ml
index 555d41c..9a5ea9e 100644
--- a/src/error/Error.ml
+++ b/src/error/Error.ml
@@ -1,6 +1,7 @@
 module Message =
 struct
   type t =
+    | FileError
     | IllegalCharacter
     | SyntaxError
     | UnboundVariable
@@ -10,6 +11,7 @@ struct
 
   let default_severity : t -> Asai.Diagnostic.severity =
     function
+    | FileError -> Error
     | IllegalCharacter -> Error
     | SyntaxError -> Error
     | UnboundVariable -> Error
@@ -19,19 +21,23 @@ struct
 
   let short_code : t -> string =
     function
+    (* operating system errors *)
+    | FileError -> "E101"
     (* parser errors *)
-    | IllegalCharacter -> "E101"
-    | SyntaxError -> "E102"
+    | IllegalCharacter -> "E201"
+    | SyntaxError -> "E202"
     (* elaboration errors *)
-    | UnboundVariable -> "E201"
-    | TypeMismatch -> "E202"
-    | NotInferable -> "E203"
+    | UnboundVariable -> "E301"
+    | TypeMismatch -> "E302"
+    | NotInferable -> "E303"
     (* misc *)
     | Bug -> "E900"
 end
 
 include Asai.Reporter.Make(Message)
 
+let file_open_error ~path ~msg = fatalf FileError
+    "unable to open file '%s': %s" path msg
 let illegal_character ~loc char = fatalf ~loc IllegalCharacter
     "illegal character '%s'" (Char.escaped char)
 let syntax_error ~loc = fatalf ~loc SyntaxError