getTracklist error handling

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: getTracklist error handling

Re: getTracklist error handling

by TIV73 » Mon Jul 17, 2017 1:34 pm

Much appreciated!

Re: getTracklist error handling

by PetrCBR » Mon Jul 17, 2017 6:15 am

Will fix getTracklist method so it will work same as getQueryResultAsync.

getTracklist error handling

by TIV73 » Thu Jun 15, 2017 12:38 pm

Hi everybody,
I noticed that executing app.db.getTracklist with an invalid query throws an exception which leaves mediamonkey unresponsive and I couldn't find a way to handle these errors.
Basically, what I'm trying to do is opening the console and running the following code

Code: Select all

app.db.getTracklist('SELECT * FROM SONGS', -1).whenLoaded().then(function () {
	console.log('ok')
}).catch((err) => {
  console.log(err)  
})
Which works fine, but once I use an invalid query in the example above, mediamonkey (rightly) complains that there was a problem executing the query, followed by a javascript error and a new promt asking if I want to restart the application. Unless I do so, mediamonkey becomes completely unresponsive, forcing me to kill the process.

getQueryResultAsync behaves slightly different:

Code: Select all

app.db.getQueryResultAsync('SELECT * FROM SONGS').then(function (result) {
	console.log('ok')
}).catch((err) => {
  console.log(err)  
})
If I execute the code above with an invalid query, the initial DB error is also pops up but mediamonkey remains usable. Another thing I noticed is that getQueryResultAsync executes the error handler and writes the error message to the log where getTracklist crashes the application before it comes to that part.

Does anybody know how I can prevent getTracklist from crashing mediamonkey or, even better, a method to handle these kind of exceptions before the users sees them?

Top