diff --git a/doc/manual.md b/doc/manual.md index d90e654264e5..40b7b9f180b9 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -5186,22 +5186,22 @@ caught by reference. Example: proc fn() = let a = initRuntimeError("foo") doAssert $a.what == "foo" - var b: cstring + var b = "" try: raise initRuntimeError("foo2") except CStdException as e: doAssert e is CStdException - b = e.what() - doAssert $b == "foo2" + b = $e.what() + doAssert b == "foo2" try: raise initStdException() except CStdException: discard try: raise initRuntimeError("foo3") except CRuntimeError as e: - b = e.what() + b = $e.what() except CStdException: doAssert false - doAssert $b == "foo3" + doAssert b == "foo3" fn() ``` diff --git a/tests/cpp/tmanual_exception.nim b/tests/cpp/tmanual_exception.nim index a91ccffe4cb2..891bccee0541 100644 --- a/tests/cpp/tmanual_exception.nim +++ b/tests/cpp/tmanual_exception.nim @@ -1,6 +1,4 @@ discard """ - # doesn't work on macos 13 seemingly due to libc++ linking issue https://stackoverflow.com/a/77375947 - disabled: osx targets: cpp """ @@ -18,21 +16,21 @@ proc initStdException(): CStdException {.importcpp: "std::exception()", construc proc fn() = let a = initRuntimeError("foo") doAssert $a.what == "foo" - var b: cstring + var b = "" try: raise initRuntimeError("foo2") except CStdException as e: doAssert e is CStdException - b = e.what() - doAssert $b == "foo2" + b = $e.what() + doAssert b == "foo2" try: raise initStdException() except CStdException: discard try: raise initRuntimeError("foo3") except CRuntimeError as e: - b = e.what() + b = $e.what() except CStdException: doAssert false - doAssert $b == "foo3" + doAssert b == "foo3" fn()