Skip to content

Commit b1b1908

Browse files
committed
making file player unsupported format error name a constant
1 parent d8d0032 commit b1b1908

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

speech-to-text/file-player.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
var getContentTypeFromHeader = require('./content-type');
44

5+
6+
57
/**
68
* Reads the first few bytes of a binary file and resolves to the content-type if recognized & supported
79
* @param {File|Blob} file
@@ -18,7 +20,7 @@ function getContentTypeFromFile(file) {
1820
resolve(ct);
1921
} else {
2022
var err = new Error('Unable to determine content type from file header; only wav, flac, and ogg/opus are supported.');
21-
err.name = 'UNSUPPORTED_FORMAT';
23+
err.name = FilePlayer.ERROR_UNSUPPORTED_FORMAT;
2224
reject(err);
2325
}
2426
};
@@ -40,7 +42,7 @@ function FilePlayer(file, contentType) {
4042
// if we emit an error, it prevents the promise from returning the actual result
4143
// however, most browsers do not support flac, so this is a reasonably scenario
4244
var err = new Error('Current browser is unable to play back ' + contentType);
43-
err.name = 'UNSUPPORTED_FORMAT';
45+
err.name = FilePlayer.ERROR_UNSUPPORTED_FORMAT;
4446
err.contentType = contentType;
4547
throw err;
4648
}
@@ -53,6 +55,8 @@ function FilePlayer(file, contentType) {
5355
};
5456
}
5557

58+
FilePlayer.ERROR_UNSUPPORTED_FORMAT = 'UNSUPPORTED_FORMAT';
59+
5660
/**
5761
* Determines the file's content-type and then resolves to a FilePlayer instance
5862
* @param {File|Blob} file

0 commit comments

Comments
 (0)