From b9512c97eec8f404997770de43ef31d7b9896e25 Mon Sep 17 00:00:00 2001 From: paresharma Date: Wed, 25 Mar 2015 20:48:17 +0100 Subject: [PATCH] Exception handling --- lib/scorm_rte.rb | 1 + lib/scorm_rte/errors.rb | 3 +++ lib/scorm_rte/lms/sco.rb | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/scorm_rte.rb b/lib/scorm_rte.rb index 616a08b..fde1eed 100644 --- a/lib/scorm_rte.rb +++ b/lib/scorm_rte.rb @@ -1,4 +1,5 @@ require 'scorm_rte/engine' +require 'scorm_rte/errors' require 'scorm_rte/lms/sco' require 'scorm_rte/lms/controllers/helpers' diff --git a/lib/scorm_rte/errors.rb b/lib/scorm_rte/errors.rb index e04a4a8..e4540e8 100644 --- a/lib/scorm_rte/errors.rb +++ b/lib/scorm_rte/errors.rb @@ -6,5 +6,8 @@ class ScormRteError < StandardError end class NoScoInstanceIdError < ScormRteError + def message + 'Always provide a unique SCO intance ID' + end end end diff --git a/lib/scorm_rte/lms/sco.rb b/lib/scorm_rte/lms/sco.rb index 0ba03c1..2db8fac 100644 --- a/lib/scorm_rte/lms/sco.rb +++ b/lib/scorm_rte/lms/sco.rb @@ -2,8 +2,8 @@ module ScormRte module Lms class Sco def initialize(sco_instance_id: nil) - unless sco_instance_id - fail NoScoInstanceIdError, 'Always provide a unique SCO intance ID' + unless sco_instance_id.present? + fail NoScoInstanceIdError end @sco_instance_id = sco_instance_id end