Skip to content

Commit

Permalink
fix(core): Exception object was not set on Cap (#5917)
Browse files Browse the repository at this point in the history
  • Loading branch information
IT-MikeS authored Sep 15, 2022
1 parent 7553ede commit 9ca27a4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
30 changes: 29 additions & 1 deletion android/capacitor/src/main/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,36 @@
/*! Capacitor: https://capacitorjs.com/ - MIT License */
/* Generated File. Do not edit. */

const nativeBridge = (function (exports) {
var nativeBridge = (function (exports) {
'use strict';

var ExceptionCode;
(function (ExceptionCode) {
/**
* API is not implemented.
*
* This usually means the API can't be used because it is not implemented for
* the current platform.
*/
ExceptionCode["Unimplemented"] = "UNIMPLEMENTED";
/**
* API is not available.
*
* This means the API can't be used right now because:
* - it is currently missing a prerequisite, such as network connectivity
* - it requires a particular platform or browser version
*/
ExceptionCode["Unavailable"] = "UNAVAILABLE";
})(ExceptionCode || (ExceptionCode = {}));
class CapacitorException extends Error {
constructor(message, code, data) {
super(message);
this.message = message;
this.code = code;
this.data = data;
}
}

// For removing exports for iOS/Android, keep let for reassignment
// eslint-disable-next-line
let dummy = {};
Expand Down Expand Up @@ -468,6 +495,7 @@ const nativeBridge = (function (exports) {
});
};
cap.withPlugin = (_pluginId, _fn) => dummy;
cap.Exception = CapacitorException;
initEvents(win, cap);
initLegacyHandlers(win, cap);
initVendor(win, cap);
Expand Down
3 changes: 3 additions & 0 deletions core/native-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
PluginResult,
WindowCapacitor,
} from './src/definitions-internal';
import { CapacitorException } from './src/util';

// For removing exports for iOS/Android, keep let for reassignment
// eslint-disable-next-line
Expand Down Expand Up @@ -552,6 +553,8 @@ const initBridge = (w: any): void => {

cap.withPlugin = (_pluginId, _fn) => dummy;

cap.Exception = CapacitorException;

initEvents(win, cap);
initLegacyHandlers(win, cap);
initVendor(win, cap);
Expand Down
30 changes: 29 additions & 1 deletion ios/Capacitor/Capacitor/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,36 @@
/*! Capacitor: https://capacitorjs.com/ - MIT License */
/* Generated File. Do not edit. */

const nativeBridge = (function (exports) {
var nativeBridge = (function (exports) {
'use strict';

var ExceptionCode;
(function (ExceptionCode) {
/**
* API is not implemented.
*
* This usually means the API can't be used because it is not implemented for
* the current platform.
*/
ExceptionCode["Unimplemented"] = "UNIMPLEMENTED";
/**
* API is not available.
*
* This means the API can't be used right now because:
* - it is currently missing a prerequisite, such as network connectivity
* - it requires a particular platform or browser version
*/
ExceptionCode["Unavailable"] = "UNAVAILABLE";
})(ExceptionCode || (ExceptionCode = {}));
class CapacitorException extends Error {
constructor(message, code, data) {
super(message);
this.message = message;
this.code = code;
this.data = data;
}
}

// For removing exports for iOS/Android, keep let for reassignment
// eslint-disable-next-line
let dummy = {};
Expand Down Expand Up @@ -468,6 +495,7 @@ const nativeBridge = (function (exports) {
});
};
cap.withPlugin = (_pluginId, _fn) => dummy;
cap.Exception = CapacitorException;
initEvents(win, cap);
initLegacyHandlers(win, cap);
initVendor(win, cap);
Expand Down

0 comments on commit 9ca27a4

Please sign in to comment.