diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd94deb13..610a1dc33c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Added +- Add error name for custom device controller error. + +### Removed + +### Fixed + +### Changed + ## [2.23.0] - 2021-11-22 ### Added - Add support for Echo Reduction when using Voice Focus. diff --git a/src/devicecontroller/GetUserMediaError.ts b/src/devicecontroller/GetUserMediaError.ts index 6c71d4e314..9d05be1a37 100644 --- a/src/devicecontroller/GetUserMediaError.ts +++ b/src/devicecontroller/GetUserMediaError.ts @@ -4,5 +4,6 @@ export default class GetUserMediaError extends Error { constructor(public cause?: Error, message?: string) { super(message || 'Error fetching device.'); + this.name = 'GetUserMediaError'; } } diff --git a/src/devicecontroller/NotFoundError.ts b/src/devicecontroller/NotFoundError.ts index 6e2c7e84b9..380d4216d2 100644 --- a/src/devicecontroller/NotFoundError.ts +++ b/src/devicecontroller/NotFoundError.ts @@ -6,5 +6,6 @@ import GetUserMediaError from './GetUserMediaError'; export default class NotFoundError extends GetUserMediaError { constructor(cause?: Error) { super(cause); + this.name = 'NotFoundError'; } } diff --git a/src/devicecontroller/NotReadableError.ts b/src/devicecontroller/NotReadableError.ts index c2e0e086cb..99827d1598 100644 --- a/src/devicecontroller/NotReadableError.ts +++ b/src/devicecontroller/NotReadableError.ts @@ -6,5 +6,6 @@ import GetUserMediaError from './GetUserMediaError'; export default class NotReadableError extends GetUserMediaError { constructor(cause?: Error) { super(cause); + this.name = 'NotReadableError'; } } diff --git a/src/devicecontroller/OverconstrainedError.ts b/src/devicecontroller/OverconstrainedError.ts index cc362f1a6a..2188eee181 100644 --- a/src/devicecontroller/OverconstrainedError.ts +++ b/src/devicecontroller/OverconstrainedError.ts @@ -6,5 +6,6 @@ import GetUserMediaError from './GetUserMediaError'; export default class OverconstrainedError extends GetUserMediaError { constructor(cause?: Error, public constraint?: string) { super(cause); + this.name = 'OverconstrainedError'; } } diff --git a/src/devicecontroller/PermissionDeniedError.ts b/src/devicecontroller/PermissionDeniedError.ts index 12ff9d6a69..fd78416f7c 100644 --- a/src/devicecontroller/PermissionDeniedError.ts +++ b/src/devicecontroller/PermissionDeniedError.ts @@ -6,5 +6,6 @@ import GetUserMediaError from './GetUserMediaError'; export default class PermissionDeniedError extends GetUserMediaError { constructor(cause?: Error, message?: string) { super(cause, message); + this.name = 'PermissionDeniedError'; } } diff --git a/src/devicecontroller/TypeError.ts b/src/devicecontroller/TypeError.ts index f958ddb484..451e4947e8 100644 --- a/src/devicecontroller/TypeError.ts +++ b/src/devicecontroller/TypeError.ts @@ -6,5 +6,6 @@ import GetUserMediaError from './GetUserMediaError'; export default class TypeError extends GetUserMediaError { constructor(cause?: Error) { super(cause); + this.name = 'TypeError'; } } diff --git a/test/devicecontroller/DefaultDeviceController.test.ts b/test/devicecontroller/DefaultDeviceController.test.ts index 6919c06dfb..035b1096d6 100644 --- a/test/devicecontroller/DefaultDeviceController.test.ts +++ b/test/devicecontroller/DefaultDeviceController.test.ts @@ -1303,6 +1303,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(NotReadableError); + expect(e.name).to.be.equal('NotReadableError'); } }); @@ -1315,6 +1316,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(NotReadableError); + expect(e.name).to.be.equal('NotReadableError'); } }); @@ -1327,6 +1329,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(NotFoundError); + expect(e.name).to.be.equal('NotFoundError'); expect(e.message).to.not.equal('This line should not be reached'); } }); @@ -1340,6 +1343,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(NotFoundError); + expect(e.name).to.be.equal('NotFoundError'); expect(e.message).to.not.equal('This line should not be reached'); } }); @@ -1353,6 +1357,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(NotReadableError); + expect(e.name).to.be.equal('NotReadableError'); expect(e.message).to.not.equal('This line should not be reached'); } }); @@ -1366,6 +1371,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(OverconstrainedError); + expect(e.name).to.be.equal('OverconstrainedError'); expect(e.message).to.not.equal('This line should not be reached'); } }); @@ -1379,6 +1385,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(OverconstrainedError); + expect(e.name).to.be.equal('OverconstrainedError'); expect(e.message).to.not.equal('This line should not be reached'); } }); @@ -1392,6 +1399,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(TypeError); + expect(e.name).to.be.equal('TypeError'); expect(e.message).to.not.equal('This line should not be reached'); } }); @@ -1405,6 +1413,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(GetUserMediaError); + expect(e.name).to.be.equal('GetUserMediaError'); expect(e.message).to.not.equal('This line should not be reached'); } }); @@ -1417,6 +1426,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(GetUserMediaError); + expect(e.name).to.be.equal('GetUserMediaError'); expect(e.message).to.not.equal('This line should not be reached'); } }); @@ -1429,6 +1439,7 @@ describe('DefaultDeviceController', () => { throw new Error('This line should not be reached'); } catch (e) { expect(e).to.be.instanceof(GetUserMediaError); + expect(e.name).to.be.equal('GetUserMediaError'); expect(e.message).to.include('Error fetching device.'); } });