refactor: errors from integrationcontroller (#700)

* refactor: these functions don't throw, test the return success and then throw

* refactor: no need to catch and re-throw
This commit is contained in:
Alex Christoffer Rasmussen
2024-01-09 16:01:17 +01:00
committed by GitHub
parent c0fb865959
commit 92cefa1331
@@ -139,11 +139,10 @@ export function dispatchFromAdapter(
throw new Error(`Event index not recognised or out of range ${eventIndex}`); throw new Error(`Event index not recognised or out of range ${eventIndex}`);
} }
try { // Indexes in frontend are 1 based
// Indexes in frontend are 1 based const success = PlaybackService.startByIndex(eventIndex - 1);
PlaybackService.startByIndex(eventIndex - 1); if (!success) {
} catch (error) { throw new Error(`Event index not recognised or out of range ${eventIndex}`);
throw new Error(`Error loading event:: ${error}`);
} }
break; break;
} }
@@ -194,11 +193,8 @@ export function dispatchFromAdapter(
if (isNaN(time)) { if (isNaN(time)) {
throw new Error(`Time not recognised ${payload}`); throw new Error(`Time not recognised ${payload}`);
} }
try {
PlaybackService.addTime(time); PlaybackService.addTime(time);
} catch (error) {
throw new Error(`Could not add time: ${error}`);
}
break; break;
} }
//deprecated //deprecated
@@ -208,11 +204,7 @@ export function dispatchFromAdapter(
throw new Error(`Delay time not recognised ${payload}`); throw new Error(`Delay time not recognised ${payload}`);
} }
try { PlaybackService.setDelay(delayTime);
PlaybackService.setDelay(delayTime);
} catch (error) {
throw new Error(`Could not add delay: ${error}`);
}
break; break;
} }
case 'gotoindex': case 'gotoindex':
@@ -222,11 +214,10 @@ export function dispatchFromAdapter(
throw new Error(`Event index not recognised or out of range ${eventIndex}`); throw new Error(`Event index not recognised or out of range ${eventIndex}`);
} }
try { // Indexes in frontend are 1 based
// Indexes in frontend are 1 based const success = PlaybackService.loadByIndex(eventIndex - 1);
PlaybackService.loadByIndex(eventIndex - 1); if (!success) {
} catch (error) { throw new Error(`Event index not recognised or out of range ${eventIndex}`);
throw new Error(`Event index not recognised or out of range ${error}`);
} }
break; break;
} }
@@ -236,10 +227,9 @@ export function dispatchFromAdapter(
throw new Error(`Event ID not recognised: ${payload}`); throw new Error(`Event ID not recognised: ${payload}`);
} }
try { const success = PlaybackService.loadById(payload.toString().toLowerCase());
PlaybackService.loadById(payload.toString().toLowerCase()); if (!success) {
} catch (error) { throw new Error(`Event ID not found: ${payload}`);
throw new Error(`OSC IN: error calling goto ${error}`);
} }
break; break;
} }
@@ -249,10 +239,9 @@ export function dispatchFromAdapter(
throw new Error(`Event cue not recognised: ${payload}`); throw new Error(`Event cue not recognised: ${payload}`);
} }
try { const success = PlaybackService.loadByCue(payload);
PlaybackService.loadByCue(payload); if (!success) {
} catch (error) { throw new Error(`Event cue not found: ${payload}`);
throw new Error(`OSC IN: error calling goto ${error}`);
} }
break; break;
} }