File: Error.hs

package info (click to toggle)
haskell-basement 0.0.16-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,048 kB
  • sloc: haskell: 11,336; ansic: 63; makefile: 5
file content (41 lines) | stat: -rw-r--r-- 1,007 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 800
{-# LANGUAGE TypeInType #-}
#endif
module Basement.Error
    ( error
    ) where

import           GHC.Prim
import           Basement.UTF8.Base
import           Basement.Compat.CallStack

#if MIN_VERSION_base(4,9,0)

import           GHC.Types (RuntimeRep)
import           GHC.Exception (errorCallWithCallStackException)

-- | stop execution and displays an error message
error :: forall (r :: RuntimeRep) . forall (a :: TYPE r) . HasCallStack => String -> a
error s = raise# (errorCallWithCallStackException (sToList s) ?callstack)

#elif MIN_VERSION_base(4,7,0)

import           GHC.Exception (errorCallException)

error :: String -> a
error s = raise# (errorCallException (sToList s))

#else

import           GHC.Types
import           GHC.Exception

error :: String -> a
error s = throw (ErrorCall (sToList s))

#endif