};
- // Attempt connection
- current_tunnel.connect(connect_data);
+ try {
+
+ // Attempt connection
+ current_tunnel.connect(connect_data);
+
+ }
+ catch (e) {
+
+ // Call error handler of current tunnel on error
+ current_tunnel.onerror(e.message);
+
+ }
+
}