mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
ERecoverableError exception contains the error message
This commit is contained in:
@@ -884,6 +884,7 @@ proc CommandRst2TeX =
|
||||
# ---------- forum ---------------------------------------------------------
|
||||
|
||||
proc setupConfig*() =
|
||||
msgs.gErrorMax = 1000_000
|
||||
setConfigVar("split.item.toc", "20")
|
||||
setConfigVar("doc.section", """
|
||||
<div class="section" id="$sectionID">
|
||||
|
||||
@@ -447,8 +447,8 @@ proc newLineInfo*(filename: string, line, col: int): TLineInfo {.inline.} =
|
||||
fileInfos.add(newFileInfo("", "command line"))
|
||||
var gCmdLineInfo* = newLineInfo(int32(0), 1, 1)
|
||||
|
||||
proc raiseRecoverableError*() {.noinline, noreturn.} =
|
||||
raise newException(ERecoverableError, "")
|
||||
proc raiseRecoverableError*(msg: string) {.noinline, noreturn.} =
|
||||
raise newException(ERecoverableError, msg)
|
||||
|
||||
var
|
||||
gNotes*: TNoteKinds = {low(TNoteKind)..high(TNoteKind)}
|
||||
@@ -560,7 +560,7 @@ proc inCheckpoint*(current: TLineInfo): TCheckPointResult =
|
||||
type
|
||||
TErrorHandling = enum doNothing, doAbort, doRaise
|
||||
|
||||
proc handleError(msg: TMsgKind, eh: TErrorHandling) =
|
||||
proc handleError(msg: TMsgKind, eh: TErrorHandling, s: string) =
|
||||
if msg == errInternal:
|
||||
assert(false) # we want a stack trace here
|
||||
if msg >= fatalMin and msg <= fatalMax:
|
||||
@@ -574,7 +574,7 @@ proc handleError(msg: TMsgKind, eh: TErrorHandling) =
|
||||
if gVerbosity >= 3: assert(false)
|
||||
quit(1) # one error stops the compiler
|
||||
elif eh == doRaise:
|
||||
raiseRecoverableError()
|
||||
raiseRecoverableError(s)
|
||||
|
||||
proc `==`(a, b: TLineInfo): bool =
|
||||
result = a.line == b.line and a.fileIndex == b.fileIndex
|
||||
@@ -606,8 +606,9 @@ proc rawMessage*(msg: TMsgKind, args: openarray[string]) =
|
||||
if not (msg in gNotes): return
|
||||
frmt = rawHintFormat
|
||||
inc(gHintCounter)
|
||||
MsgWriteln(`%`(frmt, `%`(msgKindToString(msg), args)))
|
||||
handleError(msg, doAbort)
|
||||
let s = `%`(frmt, `%`(msgKindToString(msg), args))
|
||||
MsgWriteln(s)
|
||||
handleError(msg, doAbort, s)
|
||||
|
||||
proc rawMessage*(msg: TMsgKind, arg: string) =
|
||||
rawMessage(msg, [arg])
|
||||
@@ -636,10 +637,11 @@ proc liMessage(info: TLineInfo, msg: TMsgKind, arg: string,
|
||||
ignoreMsg = optHints notin gOptions or msg notin gNotes
|
||||
frmt = posHintFormat
|
||||
inc(gHintCounter)
|
||||
let s = frmt % [toFilename(info), coordToStr(info.line),
|
||||
coordToStr(info.col), getMessageStr(msg, arg)]
|
||||
if not ignoreMsg:
|
||||
MsgWriteln(frmt % [toFilename(info), coordToStr(info.line),
|
||||
coordToStr(info.col), getMessageStr(msg, arg)])
|
||||
handleError(msg, eh)
|
||||
MsgWriteln(s)
|
||||
handleError(msg, eh, s)
|
||||
|
||||
proc Fatal*(info: TLineInfo, msg: TMsgKind, arg = "") =
|
||||
liMessage(info, msg, arg, doAbort)
|
||||
@@ -653,11 +655,6 @@ proc LocalError*(info: TLineInfo, msg: TMsgKind, arg = "") =
|
||||
proc Message*(info: TLineInfo, msg: TMsgKind, arg = "") =
|
||||
liMessage(info, msg, arg, doNothing)
|
||||
|
||||
proc GenericMessage*(info: TLineInfo, msg: TMsgKind, arg = "") =
|
||||
## does the right thing for old code that is written with "abort on first
|
||||
## error" in mind.
|
||||
liMessage(info, msg, arg, doAbort)
|
||||
|
||||
proc InternalError*(info: TLineInfo, errMsg: string) =
|
||||
writeContext(info)
|
||||
liMessage(info, errInternal, errMsg, doAbort)
|
||||
|
||||
@@ -289,10 +289,10 @@ proc tokInfo(p: TRstParser, tok: TToken): TLineInfo =
|
||||
result = newLineInfo(p.filename, p.line + tok.line, p.col + tok.col)
|
||||
|
||||
proc rstMessage(p: TRstParser, msgKind: TMsgKind, arg: string) =
|
||||
GenericMessage(tokInfo(p, p.tok[p.idx]), msgKind, arg)
|
||||
GlobalError(tokInfo(p, p.tok[p.idx]), msgKind, arg)
|
||||
|
||||
proc rstMessage(p: TRstParser, msgKind: TMsgKind) =
|
||||
GenericMessage(tokInfo(p, p.tok[p.idx]), msgKind, p.tok[p.idx].symbol)
|
||||
GlobalError(tokInfo(p, p.tok[p.idx]), msgKind, p.tok[p.idx].symbol)
|
||||
|
||||
proc currInd(p: TRstParser): int =
|
||||
result = p.indentStack[high(p.indentStack)]
|
||||
|
||||
@@ -26,7 +26,7 @@ proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
result = semExpr(c, n, flags)
|
||||
if result.kind == nkEmpty:
|
||||
# do not produce another redundant error message:
|
||||
raiseRecoverableError()
|
||||
raiseRecoverableError("")
|
||||
if result.typ != nil:
|
||||
if result.typ.kind == tyVar: result = newDeref(result)
|
||||
else:
|
||||
@@ -37,7 +37,7 @@ proc semExprNoDeref(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
result = semExpr(c, n, flags)
|
||||
if result.kind == nkEmpty:
|
||||
# do not produce another redundant error message:
|
||||
raiseRecoverableError()
|
||||
raiseRecoverableError("")
|
||||
if result.typ == nil:
|
||||
GlobalError(n.info, errExprXHasNoType,
|
||||
renderTree(result, {renderNoComments}))
|
||||
|
||||
10
web/news.txt
10
web/news.txt
@@ -19,15 +19,13 @@ Library Additions
|
||||
|
||||
- Added ``system.shallow`` that can be used to speed up string and sequence
|
||||
assignments.
|
||||
|
||||
- Added ``system.static`` that can force compile-time evaluation of certain
|
||||
expressions
|
||||
|
||||
expressions.
|
||||
- Added ``system.eval`` that can execute an anonymous block of code at
|
||||
compile time as if was a macro
|
||||
|
||||
compile time as if was a macro.
|
||||
- Added ``macros.emit`` that can emit an arbitrary computed string as nimrod
|
||||
code during compilation
|
||||
code during compilation.
|
||||
|
||||
|
||||
2012-02-09 Version 0.8.14 released
|
||||
==================================
|
||||
|
||||
Reference in New Issue
Block a user