summaryrefslogtreecommitdiff
path: root/documentation/exceptions.html
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-06 17:12:28 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-06 17:12:28 +0100
commit2bd3471192b1ebd8f3841368db4b0eaa5643bf55 (patch)
tree5940d869c49a88a5ae609fd9a877f6e2158eac40 /documentation/exceptions.html
parente48382d539bddf4c57542e2a12c4a8ddec69d0b6 (diff)
changes to documentation
Diffstat (limited to 'documentation/exceptions.html')
-rw-r--r--documentation/exceptions.html28
1 files changed, 16 insertions, 12 deletions
diff --git a/documentation/exceptions.html b/documentation/exceptions.html
index 5d136d9..1af4913 100644
--- a/documentation/exceptions.html
+++ b/documentation/exceptions.html
@@ -67,14 +67,16 @@ exception caught
</p>
<p>
The example shows how amazingly simple it is to throw exceptions from your
- C++ code, and catch them in your PHP script. Just as if you're not even
- working in two different languages at the same time, you can simply throw
- a Php::Exception object, and catch it in the PHP script.
+ C++ code, and to catch them in your PHP script. The PHP-CPP library will
+ internally catch your C++ exception and convert it into a PHP exception,
+ but this all happens under the hood. For you, the extension programmer, it
+ is as if you're not even working in two different languages, and you can
+ simply throw a Php::Exception object as if it was a regular PHP exception.
</p>
<h2>Catching exceptions in C++</h2>
<p>
But it works the other way around too. If your extensions calls a PHP
- function, and the function happens to throw an exception, you can catch it
+ function, and that PHP function happens to throw an exception, you can catch it
just as if it was a normal C++ exception.
</p>
<p>
@@ -90,7 +92,7 @@ Php::Value callMe(Php::Parameters &params)
}
catch (Php::Exception &exception)
{
- return "Exception caught!";
+ return "Exception caught!\n";
}
}
@@ -113,10 +115,11 @@ extern "C" {
</p>
<p>
The callMe() function from this example extension receives one single
- parameter: a callback function that it will immediately call, and whose
- return value is returned. If this callback function (which was supplied by
- the user) throws an exception, it is detected by the callMe() function, and
- it will return an alternative string ("Exception caught!") in stead.
+ parameter: a callback function that it will immediately call, and from which
+ the return value is also returned by the callMe() function. If this callback
+ that is passed to the callMe() somehow throws an exception, it will be caught
+ by the callMe() function, and the callMe() function will return an alternative
+ string instead ("Exception caught!").
</p>
<p>
<pre class="language-php"><code>
@@ -124,14 +127,15 @@ extern "C" {
// call "callMe" for the first time, and supply a function that returns "first call"
echo(callMe(function() {
- return "first call";
+ return "first call\n";
}));
// call "callMe" for the second time, but throw an exception this time
echo(callMe(function() {
- throw new Exception("Sorry...");
- return "second call";
+ throw new Exception("Sorry...\n");
+ return "second call\n";
}));
+?&gt;
</code></pre>
</p>
<p>