UNPKG

rn-wifi-p2p

Version:

React Native module for Android P2P communication using Wi-Fi Direct.

29 lines (27 loc) 947 B
"use strict"; // TODO: mapear todos os erros do wifi p2p export class WifiP2PError extends Error { static ERROR = 0; static P2P_UNSUPPORTED = 1; static BUSY = 2; static ERROR_MESSAGES = { [WifiP2PError.ERROR]: 'Operation failed due to an internal error.', [WifiP2PError.P2P_UNSUPPORTED]: 'P2P is unsupported on this device.', [WifiP2PError.BUSY]: 'System is busy and cannot process the request.' }; constructor(code, nativeError) { const message = WifiP2PError.ERROR_MESSAGES[code] ?? 'Unknown error.'; super(message); this.name = 'WifiP2PError'; this.code = code; this.nativeError = nativeError; } toString() { return `[${this.name}] Code: ${this.code} | Message: ${this.message}`; } static fromNativeError(error) { const code = typeof error?.code === 'number' ? error.code : WifiP2PError.ERROR; return new WifiP2PError(code, error); } } //# sourceMappingURL=WifiP2PError.js.map