Fanart: avoid NullReferenceException when there is no logo
authorAndrés G. Aragoneses <knocte@gmail.com>
Tue, 17 Sep 2013 14:50:34 +0000 (16:50 +0200)
committerAndrés G. Aragoneses <knocte@gmail.com>
Tue, 17 Sep 2013 14:50:34 +0000 (16:50 +0200)
commit1d00ee9604aebcfe6477263f8e65696e696ea733
treedc4a4b573b206036b23fc13d56c0bddbe78dcc2c
parent271e1cb5aa96a4afc8ad301e435962d1a22d95db
Fanart: avoid NullReferenceException when there is no logo

When there is no logo for a certain artist, Fanart response is simply
a string that contains the word "null". When this happened, it wouldn't
be parsed properly as JSON, obviously, which meant that the call to
method JsonObject.FromString() was returning null, which later was passed
to the constructor of CorrectResults, which would generate a NRE, which
would be caught by a try-catch which would call the constructor of
IncorrectResults class, which would receive the exception.

Seems simple enough to just convert all this cruft into code that doesn't
catch exceptions, but which also prints a warning when the response is
neither JSON nor "null".
src/Fanart/Banshee.Fanart/CorrectResults.cs
src/Fanart/Banshee.Fanart/IncorrectResults.cs
src/Fanart/Banshee.Fanart/Results.cs