In previous two blogs (Here and Here), I have shown how to experiment AIML programming, and it is not hard to turn the HelloRobot console into a GUI program. Yes, I did, and found that the robot is smart and fun.
Until, the silly me, typed below:
Me: Marry me!
It halts, and after a long time … then no response message pops.
What? Kidding me? I just want to let the robot know that! But he has lost connection with me! Why that? How to deal with this elegantly?
To know this, we need go back again to have a look at settings.xml. In there, you can see an item called “timeout”!
Change the value to “10”, rebuild and re-run the WPF application:
Now you see that a time out exception appeared after around 10 seconds, and an error message explains what happened. This is much better, but not the best. So we might try to handle the error (not exception) gracefully.
Now change it to:
Rebuild and re-run the WPF application, now, when you ask the robot to “marry you”, this is handled thoughtfully.
Yes, be nice and considerate. Robot can be naïve as well, and you should be responsible for your code to handle all kinds of exceptions and illogical responses!
Happy coding. Hm, wait, wait, where’s my coffee gone? Ask you robot and see his response!