From: Ben Beltran Date: Sat, 6 Oct 2012 08:22:26 +0000 (-0500) Subject: Document the errors... ish? X-Git-Url: https://git.r.bdr.sh/rbdr/lyricli.rb/commitdiff_plain/278e6d0afff19cce3ab8ad256c9ab8239bcf6289?hp=5d701d44f30948d6d339a8d5806a083bdf76076d Document the errors... ish? --- diff --git a/doc/Lyricli.html b/doc/Lyricli.html index d757eac..cb95933 100644 --- a/doc/Lyricli.html +++ b/doc/Lyricli.html @@ -80,7 +80,7 @@
Defined in:
lib/lyricli.rb,
- lib/lyricli/util.rb,
lib/lyricli/lyricli.rb,
lib/lyricli/sources.rb,
lib/lyricli/exceptions.rb,
lib/lyricli/sources/rdio.rb,
lib/lyricli/lyrics_engine.rb,
lib/lyricli/configuration.rb,
lib/lyricli/sources/itunes.rb,
lib/lyricli/source_manager.rb,
lib/lyricli/sources/arguments.rb
+ lib/lyricli/util.rb,
lib/lyricli/sources.rb,
lib/lyricli/lyricli.rb,
lib/lyricli/exceptions.rb,
lib/lyricli/sources/rdio.rb,
lib/lyricli/configuration.rb,
lib/lyricli/lyrics_engine.rb,
lib/lyricli/sources/itunes.rb,
lib/lyricli/source_manager.rb,
lib/lyricli/sources/arguments.rb,
lib/lyricli/exceptions/reset_source_error.rb,
lib/lyricli/exceptions/start_source_error.rb,
lib/lyricli/exceptions/enable_source_error.rb,
lib/lyricli/exceptions/unknown_source_error.rb,
lib/lyricli/exceptions/invalid_lyrics_error.rb,
lib/lyricli/exceptions/disable_source_error.rb,
lib/lyricli/exceptions/lyrics_not_found_error.rb,
lib/lyricli/exceptions/source_configuration_error.rb
@@ -313,17 +313,25 @@ Disables a source via the Source Manager
 
 
-56
-57
-58
-59
+70 +71 +72 +73 +74 +75 +76 +77 -
# File 'lib/lyricli.rb', line 56
+      
# File 'lib/lyricli.rb', line 70
 
 def self.disable(source_name)
   source_manager = SourceManager.new
-  source_manager.disable(source_name)
+  begin
+    source_manager.disable(source_name)
+  rescue Exceptions::UnknownSourceError
+    "There is no such Source"
+  end
 end
@@ -357,17 +365,25 @@ Enables a source via the Source Manager
 
 
-50
-51
-52
-53
+60 +61 +62 +63 +64 +65 +66 +67
-
# File 'lib/lyricli.rb', line 50
+      
# File 'lib/lyricli.rb', line 60
 
 def self.enable(source_name)
   source_manager = SourceManager.new
-  source_manager.enable(source_name)
+  begin
+    source_manager.enable(source_name)
+  rescue Exceptions::UnknownSourceError
+    "There is no such Source"
+  end
 end
@@ -421,13 +437,13 @@ the fetched lyrics
 
 
-30
-31
-32
-33
+40 +41 +42 +43
-
# File 'lib/lyricli.rb', line 30
+      
# File 'lib/lyricli.rb', line 40
 
 def self.lyrics
   @lyricli = Lyricli.new
@@ -465,17 +481,25 @@ Resets all configuration for a source via the Source Manager
       
 
 
-62
-63
-64
-65
+80 +81 +82 +83 +84 +85 +86 +87
-
# File 'lib/lyricli.rb', line 62
+      
# File 'lib/lyricli.rb', line 80
 
 def self.reset(source_name)
   source_manager = SourceManager.new
-  source_manager.reset(source_name)
+  begin
+    source_manager.reset(source_name)
+  rescue Exceptions::UnknownSourceError
+    "There is no such Source"
+  end
 end
@@ -528,13 +552,13 @@ the list of available sources. Enabled sources have a star appended.
 
 
-44
-45
-46
-47
+54 +55 +56 +57
-
# File 'lib/lyricli.rb', line 44
+      
# File 'lib/lyricli.rb', line 54
 
 def self.sources
   source_manager = SourceManager.new
@@ -591,12 +615,12 @@ the version
       
 
 
-37
-38
-39
+47 +48 +49
-
# File 'lib/lyricli.rb', line 37
+      
# File 'lib/lyricli.rb', line 47
 
 def self.version
   Gem.loaded_specs["lyricli"].version
@@ -611,7 +635,7 @@ the version
 
 
     
diff --git a/doc/Lyricli/Configuration.html b/doc/Lyricli/Configuration.html
index f2fa54d..54b439c 100644
--- a/doc/Lyricli/Configuration.html
+++ b/doc/Lyricli/Configuration.html
@@ -783,7 +783,7 @@ Serializes the `@config` Hash to JSON and saves it to a file.
 
 
     
diff --git a/doc/Lyricli/Exceptions.html b/doc/Lyricli/Exceptions.html
index f6acefd..5cb8e99 100644
--- a/doc/Lyricli/Exceptions.html
+++ b/doc/Lyricli/Exceptions.html
@@ -79,7 +79,9 @@
   
   
     
Defined in:
-
lib/lyricli/exceptions.rb
+
lib/lyricli/exceptions.rb,
+ lib/lyricli/exceptions/reset_source_error.rb,
lib/lyricli/exceptions/start_source_error.rb,
lib/lyricli/exceptions/enable_source_error.rb,
lib/lyricli/exceptions/unknown_source_error.rb,
lib/lyricli/exceptions/invalid_lyrics_error.rb,
lib/lyricli/exceptions/disable_source_error.rb,
lib/lyricli/exceptions/lyrics_not_found_error.rb,
lib/lyricli/exceptions/source_configuration_error.rb
+
@@ -96,7 +98,17 @@ The namespace for all exceptions in Lyricli. Has no functionality by itself
-
+

Defined Under Namespace

+

+ + + + + Classes: DisableSourceError, EnableSourceError, InvalidLyricsError, LyricsNotFoundError, ResetSourceError, SourceConfigurationError, StartSourceError, UnknownSourceError + + +

+ @@ -108,7 +120,7 @@ The namespace for all exceptions in Lyricli. Has no functionality by itself diff --git a/doc/Lyricli/Lyricli.html b/doc/Lyricli/Lyricli.html index 60c3a94..e3accb5 100644 --- a/doc/Lyricli/Lyricli.html +++ b/doc/Lyricli/Lyricli.html @@ -170,7 +170,7 @@ Exits with error when there is an empty field from the current track.

-Raises an InvalidLyricsException which means we did not get any valid +Raises an InvalidLyricsError which means we did not get any valid artist/song from any of the sources.

@@ -339,15 +339,17 @@ Exits with error when there is an empty field from the current track.
 
 
-44
-45
-46
-47
+49 +50 +51 +52 +53
-
# File 'lib/lyricli/lyricli.rb', line 44
+      
# File 'lib/lyricli/lyricli.rb', line 49
 
 def check_params
+  self.exit_with_error unless @current_track
   self.exit_with_error if @current_track[:artist].nil? or @current_track[:artist].empty?
   self.exit_with_error if @current_track[:song].nil? or @current_track[:song].empty?
 end
@@ -368,7 +370,7 @@ Exits with error when there is an empty field from the current track.

-Raises an InvalidLyricsException which means we did not get any valid +Raises an InvalidLyricsError which means we did not get any valid artist/song from any of the sources

@@ -383,7 +385,7 @@ artist/song from any of the sources
  • - (Lyricli::InvalidLyricsException) + (Lyricli::Exceptions::InvalidLyricsError) @@ -411,7 +413,7 @@ because we found nothing
    # File 'lib/lyricli/lyricli.rb', line 16
     
     def exit_with_error
    -  raise InvalidLyricsException
    +  raise Exceptions::InvalidLyricsError
     end
    @@ -476,21 +478,31 @@ the found lyrics, or a string indicating none were found 32 33 34 -35
  • +35 +36 +37 +38 +39 +40
    # File 'lib/lyricli/lyricli.rb', line 24
     
     def get_lyrics
    -  set_current_track
    -  check_params
    +
    +  begin
    +    set_current_track
    +    check_params
    +  rescue Exceptions::InvalidLyricsError
    +    return "No Artist/Song could be found :("
    +  end
     
       engine = LyricsEngine.new(@current_track[:artist], @current_track[:song])
     
       begin
    -    engine.get_lyrics
    -  rescue LyricsNotFoundException
    -    "Lyrics not found :("
    +    return engine.get_lyrics
    +  rescue Exceptions::LyricsNotFoundError
    +    return "Lyrics not found :("
       end
     end
    @@ -526,12 +538,12 @@ its current track
     
     
    -39
    -40
    -41
    +44 +45 +46
    -
    # File 'lib/lyricli/lyricli.rb', line 39
    +      
    # File 'lib/lyricli/lyricli.rb', line 44
     
     def set_current_track
       @current_track = @source_manager.current_track
    @@ -546,7 +558,7 @@ its current track
     
     
         
    diff --git a/doc/Lyricli/LyricsEngine.html b/doc/Lyricli/LyricsEngine.html
    index 0efd283..4d7c669 100644
    --- a/doc/Lyricli/LyricsEngine.html
    +++ b/doc/Lyricli/LyricsEngine.html
    @@ -365,7 +365,7 @@ the lyrics
         doc = Nokogiri::HTML(open(response['url']))
         node = doc.search(".lyricbox").first
       rescue
    -    raise Lyricli::LyricsNotFoundException
    +    raise Exceptions::LyricsNotFoundError
       end
     
       node.search(".rtMatcher").each do |n|
    @@ -388,7 +388,7 @@ the lyrics
     
     
         
    diff --git a/doc/Lyricli/SourceManager.html b/doc/Lyricli/SourceManager.html
    index 3a37bc4..a8ddaa0 100644
    --- a/doc/Lyricli/SourceManager.html
    +++ b/doc/Lyricli/SourceManager.html
    @@ -377,7 +377,7 @@ Creates a new instance of SourceManager
           current_source = klass.new
           @enabled_sources << current_source
         else
    -      raise StartSourceException
    +      raise Exceptions::StartSourceError
         end
       end
     end
    @@ -589,7 +589,7 @@ the current track, has an `:artist` and `:song` key. lock = true if source.class.name == "arguments" end rescue - raise SourceConfigurationException + raise Exceptions::SourceConfigurationError end end track @@ -670,10 +670,10 @@ the name of the source to disable @config["enabled_sources"].delete(klass.name) @config.save_config else - raise DisableSourceException + raise Exceptions::DisableSourceError end else - raise UnknownSource + raise Exceptions::UnknownSourceError end end
    @@ -757,10 +757,10 @@ the name of the source to enable @config["enabled_sources"].uniq! @config.save_config else - raise EnableSourceException + raise Exceptions::EnableSourceError end else - raise UnknownSource + raise Exceptions::UnknownSourceError end end
    @@ -927,10 +927,10 @@ the name of the source to reset. klass.reset disable(source_name) else - raise ResetSourceException + raise Exceptions::ResetSourceError end else - raise UnknownSource + raise Exceptions::UnknownSourceError end end @@ -943,7 +943,7 @@ the name of the source to reset. diff --git a/doc/Lyricli/Sources.html b/doc/Lyricli/Sources.html index 518014a..0ebaab8 100644 --- a/doc/Lyricli/Sources.html +++ b/doc/Lyricli/Sources.html @@ -120,7 +120,7 @@ The namespace for all sources in Lyricli. Has no functionality by itself diff --git a/doc/Lyricli/Sources/Arguments.html b/doc/Lyricli/Sources/Arguments.html index 934a4a7..f3678ed 100644 --- a/doc/Lyricli/Sources/Arguments.html +++ b/doc/Lyricli/Sources/Arguments.html @@ -539,7 +539,7 @@ A hash containing the current `:song` and `:artist`. diff --git a/doc/Lyricli/Sources/Itunes.html b/doc/Lyricli/Sources/Itunes.html index 349f118..e1a0f05 100644 --- a/doc/Lyricli/Sources/Itunes.html +++ b/doc/Lyricli/Sources/Itunes.html @@ -544,7 +544,7 @@ A hash containing the current `:song` and `:artist`. diff --git a/doc/Lyricli/Sources/Rdio.html b/doc/Lyricli/Sources/Rdio.html index 3336a24..d79cade 100644 --- a/doc/Lyricli/Sources/Rdio.html +++ b/doc/Lyricli/Sources/Rdio.html @@ -661,7 +661,7 @@ A hash containing the current `:song` and `:artist`. diff --git a/doc/Lyricli/Util.html b/doc/Lyricli/Util.html index a126af5..610ec2c 100644 --- a/doc/Lyricli/Util.html +++ b/doc/Lyricli/Util.html @@ -464,7 +464,7 @@ the sanitized parameter diff --git a/doc/_index.html b/doc/_index.html index 681baf6..6e81822 100644 --- a/doc/_index.html +++ b/doc/_index.html @@ -110,10 +110,32 @@ + + + + + + - - -