]> Dogcows Code - chaz/talk-event-driven-programming-in-perl/commitdiff
add slides on exception handling
authorCharles McGarvey <cmcgarvey@bluehost.com>
Sun, 17 Jun 2018 21:39:38 +0000 (15:39 -0600)
committerCharles McGarvey <cmcgarvey@bluehost.com>
Sun, 17 Jun 2018 21:39:38 +0000 (15:39 -0600)
css/slides.css
img/thorn.jpg [new file with mode: 0644]
notes.txt
slides.html

index 93fa17486d9b8bc8db50631d2fb76a3ad768a0c0..abeeb120a86f042c290051081a841c87d8d1b4d2 100644 (file)
@@ -10,7 +10,6 @@
     width: 100%;
 }
 
-
 .pizza img {
     width: 70%;
 }
     font-size: 32px;
 }
 
+#slide-not-all-roses img {
+    width: 70%;
+}
+
+.ex-exceptions .perl {
+    font-size: 38px;
+}
+
diff --git a/img/thorn.jpg b/img/thorn.jpg
new file mode 100644 (file)
index 0000000..4c7be52
Binary files /dev/null and b/img/thorn.jpg differ
index 16f2f5c0439b4377c8ed931153d5255c126e2932..0d32c72821b78cfa6b92dd54fbd93df17c9fa3a3 100644 (file)
--- a/notes.txt
+++ b/notes.txt
@@ -30,6 +30,7 @@ X kernel facilities (poll, select, etc.)
 - Exceptions in event-driven code.
 - SIGPIPE, EPIPE - might have more to do with long-lived processes rather than
   just event-driven programming, but still something to watch out for...
+- You should almost always check the return code of your syscalls to see if they succeeded or not.
 
 7. Promises:
 - Future
@@ -51,6 +52,7 @@ X What is event-driven programming?
 - C10k problem
 - EDA (event-driven architecture)
 - Benefits of Event-driven
+- How to debug event-driven code.
 
 Traditional programs:
 - CGI - web server calls your program, and your program does its thing and
index d86ee03aae1a18331b5ee606173fcdcf85011bb0..6d589b4552d0e1edcb157ecabcd8f1e42d7d6b5f 100644 (file)
@@ -445,6 +445,56 @@ while (1) {
 - [`Mojo::Reactor::Poll`](https://metacpan.org/source/Mojo::Reactor::Poll)
 ]
 
+---
+name:  not-all-roses
+class: center, middle
+
+![Thorns](img/thorn.jpg)
+
+## Watch out for the thorns...
+
+???
+There are some special considerations you need to take when writing event-driven code.
+
+---
+class: center, middle
+
+## Exceptions for error handling
+
+---
+class: center, middle
+
+### Problem: No exception handler up the call stack
+
+---
+class: ex-exceptions
+
+## Rule: Don't die/throw in event handlers.
+
+--
+### Error callback pattern
+
+```perl
+do_something_asynchronously(
+    callback => sub { ... },
+    on_error => sub { ... },
+);
+```
+
+---
+class: ex-exceptions
+
+## Rule: Don't die/throw in event handlers.
+
+### Use promises
+
+```perl
+my $promise = do_something_asynchronously();
+
+$promise->on_done(sub { ... });
+$promise->on_fail(sub { ... });
+```
+
 ---
 class: center, middle
 
This page took 0.025374 seconds and 4 git commands to generate.