Add currentExceptionAsPixieError.
This commit is contained in:
parent
f7a4bdcba7
commit
ef20501ce1
5 changed files with 17 additions and 19 deletions
|
@ -38,8 +38,7 @@ proc parseColor(s: string): Color {.raises: [PixieError]} =
|
||||||
try:
|
try:
|
||||||
result = parseHtmlColor(s)
|
result = parseHtmlColor(s)
|
||||||
except:
|
except:
|
||||||
let e = getCurrentException()
|
raise currentExceptionAsPixieError()
|
||||||
raise newException(PixieError, e.msg, e)
|
|
||||||
|
|
||||||
proc drawImage2(
|
proc drawImage2(
|
||||||
ctx: Context, image: Image, dx, dy, dWidth, dHeight: float32
|
ctx: Context, image: Image, dx, dy, dWidth, dHeight: float32
|
||||||
|
|
|
@ -79,8 +79,7 @@ proc initCtx(): Ctx =
|
||||||
result.fill = parseHtmlColor("black").rgbx
|
result.fill = parseHtmlColor("black").rgbx
|
||||||
result.stroke = parseHtmlColor("black").rgbx
|
result.stroke = parseHtmlColor("black").rgbx
|
||||||
except:
|
except:
|
||||||
let e = getCurrentException()
|
raise currentExceptionAsPixieError()
|
||||||
raise newException(PixieError, e.msg, e)
|
|
||||||
result.strokeWidth = 1
|
result.strokeWidth = 1
|
||||||
result.transform = mat3()
|
result.transform = mat3()
|
||||||
result.strokeMiterLimit = defaultMiterLimit
|
result.strokeMiterLimit = defaultMiterLimit
|
||||||
|
@ -340,8 +339,7 @@ proc decodeCtx(inherited: Ctx, node: XmlNode): Ctx =
|
||||||
except PixieError as e:
|
except PixieError as e:
|
||||||
raise e
|
raise e
|
||||||
except:
|
except:
|
||||||
let e = getCurrentException()
|
raise currentExceptionAsPixieError()
|
||||||
raise newException(PixieError, e.msg, e)
|
|
||||||
|
|
||||||
proc cairoLineCap(lineCap: LineCap): cairo.LineCap =
|
proc cairoLineCap(lineCap: LineCap): cairo.LineCap =
|
||||||
case lineCap:
|
case lineCap:
|
||||||
|
@ -526,8 +524,7 @@ proc draw(img: ptr Context, node: XmlNode, ctxStack: var seq[Ctx]) =
|
||||||
except PixieError as e:
|
except PixieError as e:
|
||||||
raise e
|
raise e
|
||||||
except:
|
except:
|
||||||
let e = getCurrentException()
|
raise currentExceptionAsPixieError()
|
||||||
raise newException(PixieError, e.msg, e)
|
|
||||||
|
|
||||||
proc decodeSvg*(data: string, width = 0, height = 0): Image =
|
proc decodeSvg*(data: string, width = 0, height = 0): Image =
|
||||||
## Render SVG file and return the image. Defaults to the SVG's view box size.
|
## Render SVG file and return the image. Defaults to the SVG's view box size.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
## Load SVG files.
|
## Load SVG files.
|
||||||
|
|
||||||
import chroma, pixie/common, pixie/images, pixie/paints, pixie/paths, strutils,
|
import chroma, pixie/common, pixie/internal, pixie/images, pixie/paints,
|
||||||
tables, vmath, xmlparser, xmltree
|
pixie/paths, strutils, tables, vmath, xmlparser, xmltree
|
||||||
|
|
||||||
when defined(pixieDebugSvg):
|
when defined(pixieDebugSvg):
|
||||||
import strtabs
|
import strtabs
|
||||||
|
@ -44,8 +44,7 @@ proc initCtx(): Ctx =
|
||||||
result.fill = parseHtmlColor("black").rgbx
|
result.fill = parseHtmlColor("black").rgbx
|
||||||
result.stroke = parseHtmlColor("black").rgbx
|
result.stroke = parseHtmlColor("black").rgbx
|
||||||
except:
|
except:
|
||||||
let e = getCurrentException()
|
raise currentExceptionAsPixieError()
|
||||||
raise newException(PixieError, e.msg, e)
|
|
||||||
result.strokeWidth = 1
|
result.strokeWidth = 1
|
||||||
result.transform = mat3()
|
result.transform = mat3()
|
||||||
result.strokeMiterLimit = defaultMiterLimit
|
result.strokeMiterLimit = defaultMiterLimit
|
||||||
|
@ -323,8 +322,7 @@ proc decodeCtx(inherited: Ctx, node: XmlNode): Ctx =
|
||||||
except PixieError as e:
|
except PixieError as e:
|
||||||
raise e
|
raise e
|
||||||
except:
|
except:
|
||||||
let e = getCurrentException()
|
raise currentExceptionAsPixieError()
|
||||||
raise newException(PixieError, e.msg, e)
|
|
||||||
|
|
||||||
proc fill(img: Image, ctx: Ctx, path: Path) {.inline.} =
|
proc fill(img: Image, ctx: Ctx, path: Path) {.inline.} =
|
||||||
if ctx.display and ctx.opacity > 0:
|
if ctx.display and ctx.opacity > 0:
|
||||||
|
@ -560,8 +558,7 @@ proc draw(img: Image, node: XmlNode, ctxStack: var seq[Ctx]) =
|
||||||
except PixieError as e:
|
except PixieError as e:
|
||||||
raise e
|
raise e
|
||||||
except:
|
except:
|
||||||
let e = getCurrentException()
|
raise currentExceptionAsPixieError()
|
||||||
raise newException(PixieError, e.msg, e)
|
|
||||||
|
|
||||||
proc decodeSvg*(
|
proc decodeSvg*(
|
||||||
data: string, width = 0, height = 0
|
data: string, width = 0, height = 0
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import pixie/common, pixie/paths, strutils, tables, unicode, vmath, xmlparser, xmltree
|
import pixie/common, pixie/internal, pixie/paths, strutils, tables, unicode,
|
||||||
|
vmath, xmlparser, xmltree
|
||||||
|
|
||||||
type SvgFont* = ref object
|
type SvgFont* = ref object
|
||||||
unitsPerEm*, ascent*, descent*: float32
|
unitsPerEm*, ascent*, descent*: float32
|
||||||
|
@ -42,8 +43,7 @@ proc parseSvgFont*(buf: string): SvgFont {.raises: [PixieError].} =
|
||||||
try:
|
try:
|
||||||
parseXml(buf)
|
parseXml(buf)
|
||||||
except:
|
except:
|
||||||
let e = getCurrentException()
|
raise currentExceptionAsPixieError()
|
||||||
raise newException(PixieError, e.msg, e)
|
|
||||||
|
|
||||||
let defs = root.child("defs")
|
let defs = root.child("defs")
|
||||||
if defs == nil:
|
if defs == nil:
|
||||||
|
|
|
@ -3,6 +3,11 @@ import chroma, vmath
|
||||||
when defined(amd64) and not defined(pixieNoSimd):
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
import nimsimd/sse2
|
import nimsimd/sse2
|
||||||
|
|
||||||
|
template currentExceptionAsPixieError*(): untyped =
|
||||||
|
## Gets the current exception and returns it as a PixieError with stack trace.
|
||||||
|
let e = getCurrentException()
|
||||||
|
newException(PixieError, e.getStackTrace & e.msg, e)
|
||||||
|
|
||||||
proc gaussianKernel*(radius: int): seq[uint16] {.raises: [].} =
|
proc gaussianKernel*(radius: int): seq[uint16] {.raises: [].} =
|
||||||
## Compute lookup table for 1d Gaussian kernel.
|
## Compute lookup table for 1d Gaussian kernel.
|
||||||
## Values are [0, 255] * 256.
|
## Values are [0, 255] * 256.
|
||||||
|
|
Loading…
Reference in a new issue