I'm wrapping an imported SDK class with a Proxy so that I can eventually catch RequestExceptions, i.e. when there is no network connection to display error popups.
The app is working without issues in remote debugging mode, however, when I disable it the error Can't find Variable: Proxy
is thrown. Do I need to import this explicitly somehow? Or is there an alternative method to wrap a class so that I can catch all of its exceptions?
Below is the code for the Proxy wrapper.
import Backend from 'backend-sdk'; import RequestException from 'backend-sdk/src/exceptions/RequestException'; let handler = { get: (target, name, receiver) => { try { return Reflect.get(target, name, receiver); } catch (e) { if (e instanceof RequestException) { console.error(e); //TODO Add a toast notification for failed API requests } else { throw e; } } } }; export default new Proxy(new Backend(), handler);