From 2f088413aabc7cd1511ec7f15dc947ed6c609ca0 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Tue, 4 Aug 2020 16:28:22 -0700 Subject: [PATCH] unsupported browser exception proposal --- core/src/plugins.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/src/plugins.ts b/core/src/plugins.ts index 65d7562f1..897c922d7 100644 --- a/core/src/plugins.ts +++ b/core/src/plugins.ts @@ -1,6 +1,28 @@ import { Capacitor, Plugins } from './global'; import { WebPlugin } from './web'; +export enum ExceptionCodes { + UNSUPPORTED_BROWSER = 'UNSUPPORTED_BROWSER', +} + +export class Exception extends Error { + readonly code: ExceptionCodes; +} + +/** + * Feature unavailable for the current browser (or all browsers). + * + * This error is thrown when the requested API is not supported in the browser. + * + * This can happen particularly for the web platform when implementation is + * uncertain due to the plethora of browsers available to end users. + * + * Error code: `UNSUPPORTED_BROWSER` + */ +export class UnsupportedBrowserException extends Exception { + code = ExceptionCodes.UNSUPPORTED_BROWSER; +} + const PLUGIN_REGISTRY = new (class { protected readonly plugins: { [plugin: string]: RegisteredPlugin;