How to use the streamr-client-protocol.Errors.InvalidJsonError function in streamr-client-protocol

To help you get started, we’ve selected a few streamr-client-protocol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github streamr-dev / streamr-client-javascript / src / StreamrClient.js View on Github external
this.connection.on('error', (err) => {
            // If there is an error parsing a json message in a stream, fire error events on the relevant subs
            if (err instanceof Errors.InvalidJsonError) {
                const stream = this._getSubscribedStreamPartition(err.streamMessage.getStreamId(), err.streamMessage.getStreamPartition())
                if (stream) {
                    stream.getSubscriptions().forEach((sub) => sub.handleError(err))
                } else {
                    debug('WARN: InvalidJsonError received for stream with no subscriptions: %s', err.streamId)
                }
            } else {
                // if it looks like an error emit as-is, otherwise wrap in new Error
                const errorObject = (err && err.stack && err.message) ? err : new Error(err)
                this.emit('error', errorObject)
                console.error(errorObject)
            }
        })
    }
github streamr-dev / streamr-client-javascript / src / AbstractSubscription.js View on Github external
handleError(err) {
        /**
         * If parsing the (expected) message failed, we should still mark it as received. Otherwise the
         * gap detection will think a message was lost, and re-request the failing message.
         */
        if (err instanceof Errors.InvalidJsonError && err.streamMessage && this.orderingUtil) {
            this.orderingUtil.markMessageExplicitly(err.streamMessage)
        }
        this.emit('error', err)
    }

streamr-client-protocol

JavaScript classes implementing the Streamr client-to-node protocol

Apache-2.0
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis

Similar packages