lib/pandorified/session.rb in pandorified-0.6.0 vs lib/pandorified/session.rb in pandorified-0.7.0
- old
+ new
@@ -1,6 +1,7 @@
require 'pandorified/result'
+require 'pandorified/exceptions'
module Pandorified
class Session
# A new session for conversing with a bot.
#
@@ -12,20 +13,21 @@
@botid = botid
@custid = custid
end
# Send a message to this session's bot and receive a response.
+ # If Pandorabots responds with an error, {Pandorified::Exceptions::PandorabotsError} is raised.
#
# @param [String] input Text to say to the bot.
#
# @return [String] The bot's response text.
def talk(input)
result = Pandorified::Result.new(botid: @botid, custid: @custid, input: input)
if result.status.zero?
@custid ||= result.custid
result.that
else
- raise "Pandorabots returned status #{result.status}: #{result.message}"
+ raise Pandorified::Exceptions::PandorabotsError, "Pandorabots returned status #{result.status}: #{result.message}"
end
end
end
end