source: gs3-extensions/web-audio/trunk/js-mad/sink.js-master/src/core/error.js@ 28388

Last change on this file since 28388 was 28388, checked in by davidb, 11 years ago

Set of JS, CSS, PNG etc web resources to support a mixture of audio player/document display capabilities

File size: 1.5 KB
Line 
1void function (Sink) {
2
3/*
4 * A Sink-specific error class.
5 *
6 * @class
7 * @static Sink
8 * @name Error
9 *
10 * @arg =code
11 *
12 * @param {Number} code The error code.
13 * @param {String} message A brief description of the error.
14 * @param {String} explanation A more verbose explanation of why the error occured and how to fix.
15*/
16
17function SinkError(code) {
18 if (!SinkError.hasOwnProperty(code)) throw SinkError(1);
19 if (!(this instanceof SinkError)) return new SinkError(code);
20
21 var k;
22 for (k in SinkError[code]) {
23 if (SinkError[code].hasOwnProperty(k)) {
24 this[k] = SinkError[code][k];
25 }
26 }
27
28 this.code = code;
29}
30
31SinkError.prototype = new Error();
32
33SinkError.prototype.toString = function () {
34 return 'SinkError 0x' + this.code.toString(16) + ': ' + this.message;
35};
36
37SinkError[0x01] = {
38 message: 'No such error code.',
39 explanation: 'The error code does not exist.'
40};
41SinkError[0x02] = {
42 message: 'No audio sink available.',
43 explanation: 'The audio device may be busy, or no supported output API is available for this browser.'
44};
45
46SinkError[0x10] = {
47 message: 'Buffer underflow.',
48 explanation: 'Trying to recover...'
49};
50SinkError[0x11] = {
51 message: 'Critical recovery fail.',
52 explanation: 'The buffer underflow has reached a critical point, trying to recover, but will probably fail anyway.'
53};
54SinkError[0x12] = {
55 message: 'Buffer size too large.',
56 explanation: 'Unable to allocate the buffer due to excessive length, please try a smaller buffer. Buffer size should probably be smaller than the sample rate.'
57};
58
59Sink.Error = SinkError;
60
61}(this.Sink);
Note: See TracBrowser for help on using the repository browser.