Skip to content

Commit 2f64e21

Browse files
committed
less cryptic error message for missing protocols
1 parent 3ae98ec commit 2f64e21

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

js/database.js

+30-35
Original file line numberDiff line numberDiff line change
@@ -285,48 +285,43 @@ class Database {
285285
}
286286

287287
checkDuplicate(file, callback) {
288-
try {
289-
let header = Parser.getHeader(file);
288+
let header = Parser.getHeader(file);
290289

291-
if (header.err) {
292-
callback(header.err);
293-
return;
294-
}
290+
if (header.err) {
291+
callback(header.err);
292+
return;
293+
}
295294

296-
let search = {};
295+
let search = {};
297296

298-
// duplicate criteria:
299-
// same type
300-
search.type = header.type;
297+
// duplicate criteria:
298+
// same type
299+
search.type = header.type;
301300

302-
//search.loopLength = data.header.m_elapsedGameLoops;
303-
304-
// same map
305-
search.map = header.map;
306-
307-
// same players
308-
// they should be in identical order but just in case
309-
search.$and = [];
310-
for (let p of header.playerIDs) {
311-
search.$and.push({ playerIDs: p });
312-
}
301+
//search.loopLength = data.header.m_elapsedGameLoops;
302+
303+
// same map
304+
search.map = header.map;
313305

314-
// date within 1 minute
315-
let dateMin = new Date(header.date.getTime() - 60000);
316-
let dateMax = new Date(header.date.getTime() + 60000);
317-
search.$where = function() {
318-
let d = new Date(this.date);
319-
return dateMin <= d && d <= dateMax;
320-
}
321-
322-
// this is the one raw call that is not preprocessed by collections for what should be somewhat obvious reasons
323-
this._db.matches.find(search, function(err, docs) {
324-
callback(docs.length > 0);
325-
});
306+
// same players
307+
// they should be in identical order but just in case
308+
search.$and = [];
309+
for (let p of header.playerIDs) {
310+
search.$and.push({ playerIDs: p });
326311
}
327-
catch (err) {
328-
callback('Internal Exception');
312+
313+
// date within 1 minute
314+
let dateMin = new Date(header.date.getTime() - 60000);
315+
let dateMax = new Date(header.date.getTime() + 60000);
316+
search.$where = function() {
317+
let d = new Date(this.date);
318+
return dateMin <= d && d <= dateMax;
329319
}
320+
321+
// this is the one raw call that is not preprocessed by collections for what should be somewhat obvious reasons
322+
this._db.matches.find(search, function(err, docs) {
323+
callback(docs.length > 0);
324+
});
330325
}
331326

332327
// counts the given matches

js/settings.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,13 @@ function parseReplaysAsync(replay) {
419419
else {
420420
console.log(replay.id + ' Parser error');
421421

422-
$('tr[replay-id="' + replay.id + '"] .replay-status').text('Error: Internal Exception').addClass('negative');
422+
// this message is specifically for when a protocol doesn't exist
423+
if (result.message === "Cannot read property 'decodeReplayHeader' of undefined") {
424+
$('tr[replay-id="' + replay.id + '"] .replay-status').text('Error: Missing Replay Protocol').addClass('negative');
425+
}
426+
else {
427+
$('tr[replay-id="' + replay.id + '"] .replay-status').text('Error: Internal Exception').addClass('negative');
428+
}
423429
}
424430

425431
listedReplays[replay.idx].processed = true;

0 commit comments

Comments
 (0)