nations/spoticord

Issue when closing spotify, would love to recreate this. Finna rewrite this so much better.

Opened this issue · 4 comments

When closing spotify this happens, javascript doesn't seem to be your strong suit. But bugs happen.

C:\Users\Tetrabyte\Documents\spoticord\app.js:59
    if (!res.track.track_resource || !res.track.artist_resource) return;
                  ^

TypeError: Cannot read property 'track_resource' of undefined
    at C:\Users\Tetrabyte\Documents\spoticord\app.js:59:19
    at Request._callback (C:\Users\Tetrabyte\Documents\spoticord\spotify.js:59:16)
    at Request.self.callback (C:\Users\Tetrabyte\Documents\spoticord\node_modules\request\request.js:186:22)
    at emitTwo (events.js:125:13)
    at Request.emit (events.js:213:7)
    at Request.<anonymous> (C:\Users\Tetrabyte\Documents\spoticord\node_modules\request\request.js:1163:10)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at IncomingMessage.<anonymous> (C:\Users\Tetrabyte\Documents\spoticord\node_modules\request\request.js:1085:12)
    at Object.onceWrapper (events.js:314:30)
tilda commented

Well this is obvious. Since you just closed Spotify, you obviously can't retrieve the track so the object is just undefined

Okay but listen, yes I closed spotify but this error can be caught... Should be caught, you should never have code with errors in it...

@thetetrabyte is actually right. Never have code run issues. Just check for "undefined" and emit the process. It's very much needed, especially when you run Spoticord with a process manager like pm2.