[Time Conductor] Throw errors for unknown formats

Per code review, nasa/openmctweb#204
This commit is contained in:
Victor Woeltjen
2015-11-02 12:23:13 -08:00
parent 796d6b800a
commit a1d765f271
3 changed files with 8 additions and 11 deletions

View File

@ -85,7 +85,7 @@ define([
* @param {Array.<function(new : Format)>} format constructors,
* from the `formats` extension category.
*/
function FormatProvider(formats, $log) {
function FormatProvider(formats) {
var formatMap = {};
function addToMap(Format) {
@ -97,13 +97,12 @@ define([
formats.forEach(addToMap);
this.formatMap = formatMap;
this.$log = $log;
}
FormatProvider.prototype.getFormat = function (key) {
var format = this.formatMap[key];
if (!format) {
this.$log.warn("No format found for " + key);
throw new Error("FormatProvider: No format found for " + key);
}
return format;
};