Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / error.sml
CommitLineData
7f918cf1
CE
1(* Copyright (C) 2017 Matthew Fluet.
2 * Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 *)
8
9structure Error: ERROR =
10struct
11
12fun bug msg = raise (Fail msg)
13
14fun reraise (exn, {prefix, suffix}) =
15 bug (concat [prefix,
16 case exn of
17 Fail msg => msg
18 | _ => General.exnName exn,
19 suffix])
20
21fun reraisePrefix (exn, msg) = reraise (exn, {prefix = msg, suffix = ""})
22fun reraiseSuffix (exn, msg) = reraise (exn, {prefix = "", suffix = msg})
23
24fun unimplemented msg = raise Fail (concat ["unimplemented: ", msg])
25
26fun warning msg = TextIO.output (TextIO.stdErr, concat [msg, "\n"])
27
28end