@cafebazaar/react-native-poolakey
Version:
ReactNative implementation of CafeBazaar's in-app payment SDK
35 lines (33 loc) • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ItemNotFoundError = exports.DisconnectedError = exports.BazaarNotFoundError = void 0;
exports.praseError = praseError;
// DisconnectException: We can't communicate with Bazaar: Service is disconnected
// NotFoundException: Item not found
// BazaarNotFoundException: Bazaar is not installed
class DisconnectedError extends Error {}
exports.DisconnectedError = DisconnectedError;
class ItemNotFoundError extends Error {}
exports.ItemNotFoundError = ItemNotFoundError;
class BazaarNotFoundError extends Error {}
exports.BazaarNotFoundError = BazaarNotFoundError;
function createError(ExceptionClass, e) {
const customException = new ExceptionClass(e.message);
Object.assign(customException, e);
return customException;
}
function praseError(e) {
if (e.message === 'Item not found') {
return createError(ItemNotFoundError, e);
}
if (e.message === "We can't communicate with Bazaar: Service is disconnected") {
return createError(DisconnectedError, e);
}
if (e.message === 'Bazaar is not installed') {
return createError(BazaarNotFoundError, e);
}
return e;
}
//# sourceMappingURL=exceptions.js.map