File: .lake/packages/lean4/src/lean/Lean/Exception.lean

full_name: Lean.Exception
code: /-- Exception type used in most Lean monads -/
inductive Exception where
  /-- Error messages that are displayed to users. `ref` is used to provide position information. -/
  | error (ref : Syntax) (msg : MessageData)
  /--
  Internal exceptions that are not meant to be seen by users.
  Examples: "postpone elaboration", "stuck at universe constraint", etc.
  -/
  | internal (id : InternalExceptionId) (extra : KVMap := {})
goal: Type

full_name: Lean.Exception.internal
code: /-- Exception type used in most Lean monads -/
inductive Exception where
  /-- Error messages that are displayed to users. `ref` is used to provide position information. -/
  | error (ref : Syntax) (msg : MessageData)
  /--
  Internal exceptions that are not meant to be seen by users.
  Examples: "postpone elaboration", "stuck at universe constraint", etc.
  -/
  | internal (id : InternalExceptionId) (extra : KVMap := {})
goal: Lean.Exception

full_name: Lean.Exception.error
code: /-- Exception type used in most Lean monads -/
inductive Exception where
  /-- Error messages that are displayed to users. `ref` is used to provide position information. -/
  | error (ref : Syntax) (msg : MessageData)
  /--
  Internal exceptions that are not meant to be seen by users.
  Examples: "postpone elaboration", "stuck at universe constraint", etc.
  -/
  | internal (id : InternalExceptionId) (extra : KVMap := {})
goal: Lean.Exception

full_name: Lean.Exception.toMessageData
code: /-- Convert exception into a structured message. -/
def Exception.toMessageData : Exception → MessageData
  
goal: Lean.Exception → Lean.MessageData

full_name: Lean.Exception.hasSyntheticSorry
code: def Exception.hasSyntheticSorry : Exception → Bool
  
goal: Lean.Exception → Bool

full_name: Lean.Exception.getRef
code: /--
Return syntax object providing position information for the exception.
Recall that internal exceptions do not have position information.
-/
def Exception.getRef : Exception → Syntax
  
goal: Lean.Exception → Lean.Syntax

full_name: Lean.instInhabitedException
code: instance : Inhabited Exception 
goal: Inhabited Lean.Exception

full_name: Lean.AddErrorMessageContext.add
code: /-- Similar to `AddMessageContext`, but for error messages.
   The default instance just uses `AddMessageContext`.
   In error messages, we may want to provide additional information (e.g., macro expansion stack),
   and refine the `(ref : Syntax)`. -/
class AddErrorMessageContext (m : Type → Type) where
  add : Syntax → MessageData → m (Syntax × MessageData)
goal: Lean.Syntax → Lean.MessageData → m (Lean.Syntax × Lean.MessageData)

full_name: Lean.AddErrorMessageContext
code: /-- Similar to `AddMessageContext`, but for error messages.
   The default instance just uses `AddMessageContext`.
   In error messages, we may want to provide additional information (e.g., macro expansion stack),
   and refine the `(ref : Syntax)`. -/
class AddErrorMessageContext (m : Type → Type) where
  add : Syntax → MessageData → m (Syntax × MessageData)
goal: Type

full_name: Lean.instAddErrorMessageContextOfAddMessageContextOfMonad
code: instance (m : Type → Type) [AddMessageContext m] [Monad m] : AddErrorMessageContext m 
goal: Lean.AddErrorMessageContext m

full_name: Lean.MonadError.mk
code: class abbrev MonadError (m : Type → Type) :=
  MonadExceptOf Exception m
  MonadRef m
  AddErrorMessageContext m
goal: Lean.MonadError m

full_name: Lean.MonadError
code: class abbrev MonadError (m : Type → Type) :=
  MonadExceptOf Exception m
  MonadRef m
  AddErrorMessageContext m
goal: Type 1

full_name: Lean.throwError
code: /--
Throw an error exception using the given message data.
The result of `getRef` is used as position information.
Recall that `getRef` returns the current "reference" syntax.
-/
protected def throwError [Monad m] [MonadError m] (msg : MessageData) : m α 
goal: m α

full_name: Lean.throwUnknownConstant
code: /-- Throw an unknown constant error message. -/
def throwUnknownConstant [Monad m] [MonadError m] (constName : Name) : m α 
goal: m α

full_name: Lean.throwErrorAt
code: /-- Throw an error exception using the given message data and reference syntax. -/
protected def throwErrorAt [Monad m] [MonadError m] (ref : Syntax) (msg : MessageData) : m α 
goal: m α

full_name: Lean.ofExcept
code: /--
Convert an `Except` into a `m` monadic action, where `m` is any monad that
implements `MonadError`.
-/
def ofExcept [Monad m] [MonadError m] [ToString ε] (x : Except ε α) : m α 
goal: m α

full_name: Lean.throwKernelException
code: /--
Throw an error exception for the given kernel exception.
-/
def throwKernelException [Monad m] [MonadError m] [MonadOptions m] (ex : KernelException) : m α 
goal: m α

full_name: Lean.ofExceptKernelException
code: /-- Lift from `Except KernelException` to `m` when `m` can throw kernel exceptions. -/
def ofExceptKernelException [Monad m] [MonadError m] [MonadOptions m] (x : Except KernelException α) : m α 
goal: m α

full_name: Lean.MonadRecDepth.withRecDepth
code: class MonadRecDepth (m : Type → Type) where
  withRecDepth {α} : Nat → m α → m α
  getRecDepth      : m Nat
  getMaxRecDepth   : m Nat
goal: Nat → m α → m α

full_name: Lean.MonadRecDepth
code: class MonadRecDepth (m : Type → Type) where
  withRecDepth {α} : Nat → m α → m α
  getRecDepth      : m Nat
  getMaxRecDepth   : m Nat
goal: Type 1

full_name: Lean.MonadRecDepth.getRecDepth
code: class MonadRecDepth (m : Type → Type) where
  withRecDepth {α} : Nat → m α → m α
  getRecDepth      : m Nat
  getMaxRecDepth   : m Nat
goal: m Nat

full_name: Lean.MonadRecDepth.getMaxRecDepth
code: class MonadRecDepth (m : Type → Type) where
  withRecDepth {α} : Nat → m α → m α
  getRecDepth      : m Nat
  getMaxRecDepth   : m Nat
goal: m Nat

full_name: Lean.instMonadRecDepthReaderTOfMonad
code: instance [Monad m] [MonadRecDepth m] : MonadRecDepth (ReaderT ρ m) 
goal: Lean.MonadRecDepth (ReaderT ρ m)

full_name: Lean.instMonadRecDepthStateRefT'OfMonad
code: instance [Monad m] [MonadRecDepth m] : MonadRecDepth (StateRefT' ω σ m) 
goal: Lean.MonadRecDepth (StateRefT' ω σ m)

full_name: Lean.instMonadRecDepthMonadCacheTOfMonad
code: instance [BEq α] [Hashable α] [Monad m] [STWorld ω m] [MonadRecDepth m] : MonadRecDepth (MonadCacheT α β m) 
goal: Lean.MonadRecDepth (Lean.MonadCacheT α β m)

full_name: Lean.throwMaxRecDepthAt
code: /--
Throw a "maximum recursion depth has been reached" exception using the given reference syntax.
-/
def throwMaxRecDepthAt [MonadError m] (ref : Syntax) : m α 
goal: m α

full_name: Lean.Exception.isMaxRecDepth
code: /--
Return true if `ex` was generated by `throwMaxRecDepthAt`.
This function is a bit hackish. The max rec depth exception should probably be an internal exception,
but it is also produced by `MacroM` which implemented in the prelude, and internal exceptions have not
been defined yet.
-/
def Exception.isMaxRecDepth (ex : Exception) : Bool 
goal: Bool

full_name: Lean.withIncRecDepth
code: /--
Increment the current recursion depth and then execute `x`.
Throw an exception if maximum recursion depth has been reached.
We use this combinator to prevent stack overflows.
-/
@[inline] def withIncRecDepth [Monad m] [MonadError m] [MonadRecDepth m] (x : m α) : m α 
goal: m α

full_name: Lean.termThrowError__
code: /--
Macro for throwing error exceptions. The argument can be an interpolated string.
It is a convenient way of building `MessageData` objects.
The result of `getRef` is used as position information.
Recall that `getRef` returns the current "reference" syntax.
-/
syntax "throwError " (interpolatedStr(term) <|> term) : term
goal: Lean.ParserDescr

full_name: Lean.termThrowErrorAt____
code: /--
Macro for throwing error exceptions. The argument can be an interpolated string.
It is a convenient way of building `MessageData` objects.
The first argument must be a `Syntax` that provides position information for
the error message.
`throwErrorAt ref msg` is equivalent to `withRef ref <| throwError msg`
-/
syntax "throwErrorAt " term:max ppSpace (interpolatedStr(term) <|> term) : term
goal: Lean.ParserDescr

full_name: Lean.«_aux_.lake_packages_lean4_src_lean_Lean_Exception___macroRules_Lean_termThrowError___1»
code: macro_rules
  | `(throwError $msg:interpolatedStr) => `(Lean.throwError (m! $msg))
  | `(throwError $msg:term)            => `(Lean.throwError $msg)
goal: Lean.Macro

full_name: Lean.«_aux_.lake_packages_lean4_src_lean_Lean_Exception___macroRules_Lean_termThrowErrorAt_____1»
code: macro_rules
  | `(throwErrorAt $ref $msg:interpolatedStr) => `(Lean.throwErrorAt $ref (m! $msg))
  | `(throwErrorAt $ref $msg:term)            => `(Lean.throwErrorAt $ref $msg)
goal: Lean.Macro