Browse Source
Merge pull request #2062 from svaarala/improve-safe-to-string-apidoc
Improve duk_safe_to_string() API documentation
pull/2066/head
Sami Vaarala
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
11 additions and
3 deletions
-
website/api/duk_safe_to_string.yaml
|
|
@ -9,12 +9,20 @@ stack: | |
|
|
|
summary: | |
|
|
|
<p>Like <code><a href="#duk_to_string">duk_to_string()</a></code> but if |
|
|
|
the initial string coercion fails, the error value is coerced to a string. |
|
|
|
If that also fails, a fixed error string is returned.</p> |
|
|
|
If that also fails, a fixed pre-allocated error string <code>"Error"</code> |
|
|
|
is used instead (because the string is pre-allocated, this cannot fail due to |
|
|
|
out-of-memory).</p> |
|
|
|
|
|
|
|
<p>The caller can safely use this function to coerce a value to a string, |
|
|
|
which is useful in C code to print out a return value safely with |
|
|
|
<code>printf()</code>. The only uncaught errors possible are out-of-memory |
|
|
|
and other internal errors which trigger fatal error handling anyway.</p> |
|
|
|
<code>printf()</code>. The only uncaught errors possible are internal |
|
|
|
errors which trigger fatal error handling anyway.</p> |
|
|
|
|
|
|
|
<div class="note"> |
|
|
|
While the string coercion is safe from error throws, it may have side |
|
|
|
effects in the current implementation. In particular, the string coercion |
|
|
|
may enter an infinite loop and never return. |
|
|
|
</div> |
|
|
|
|
|
|
|
example: | |
|
|
|
/* Coercion causes error. */ |
|
|
|