Error Handling
Completely optional. Some of the GLOW functions are asynchronous (this is noted where applicable), and therefore can fail. In advanced use cases, you may want to handle these yourself.
You don't need to worry about showing errors, we take care of it for you.
If an error occurs, such as a storage permission issue, we automatically display an error message on screen so you don't need custom error handling code. However for completeness, the returned Promise will reject with a string matching one of the below values, in case you want to do something with it (for example, logging it).
Example:
glow.addProductToShow({ brandId: 'brand_id', productId: 'product_id' })
.catch((reason) => {
if (reason === 'storage-error') {
// handle storage error
} else if (reason === 'timeout') {
// handle storage error
}
});
Error String Reference
"storage-error"
This is triggered if a user has disabled 3rd-party storage in their browser, or is using a strict privacy-oriented browser that does the same. In this case show data can't be read or written to. The GLOW library and related applications will notify users about this.
"timeout"
Extremely rare, but possible. Can be fixed by retrying. The reason is the asynchronous GLOW functions use an <iframe> and postMessage to communicate with the GLOW domain, and if the user's internet connection changes or fails while this iframe is loading, it can timeout. Assuming the user's internet becomes stable again, a retry will fix the issue.