Skip to content

Better serialization errors #1089

@delvedor

Description

@delvedor

Currently, the SerializationError and DeserializationError make easy to understand what went wrong, but not why.
The bad object/string is not part of the error, which makes more complex the debugging experience.

This can be easily improved by adding a data field to both the error classes:

class DeserializationError extends ElasticsearchClientError {
-  constructor (message) {
+  constructor (message, data) {
    super(message)
    Error.captureStackTrace(this, DeserializationError)
    this.name = 'DeserializationError'
    this.message = message || 'Deserialization Error'
+   this.data = data
  }
}

Then the code should be updated accordingly in lib/Serialize.js and in lib/errors.d.ts.

Related: #1088

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions