question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a type for a search error response

See original GitHub issue

The Elasticsearch client needs a type representing an ES error. It would be amazing to also have a type guard isElasticseachError, that accepts either a SearchResponse or a ErrorResponse and returns true if it’s an error.

A standard response looks like this:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "Unknown order direction [xxx]",
        "line" : 7,
        "col" : 16
      }
    ],
    "type" : "x_content_parse_exception",
    "reason" : "[7:16] [terms] failed to parse field [order]",
    "caused_by" : {
      "type" : "parsing_exception",
      "reason" : "Unknown order direction [xxx]",
      "line" : 7,
      "col" : 16
    }
  },
  "status" : 400
}

It can be generated by running the following command in DevTools:

GET kibana_sample_data_logs/_search
{
  "aggs": {
    "2": {
      "terms": {
        "field": "machine.os.keyword",
        "order": {
          "1": "xxx"
        }
      }
    }
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lizozomcommented, Oct 5, 2020

I’m fine with closing it and \ or waiting until the new client provides types 🤷‍♀️

0reactions
delvedorcommented, Oct 5, 2020

at the moment, the new Elasticsearch Client doesn’t provide types for responses at all.

Correct.

if an error is returned but “ignored,” the error response follows the normal response path but does not match the SearchResponse type.

Also correct.

I’m not sure how this could be solved nicely.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Standard Error Responses | Search Ads 360 API
This document identifies some of the error codes and messages that Google APIs return. Specifically, the errors listed here are in the global,...
Read more >
<input type="search"> - HTML: HyperText Markup Language
It should be a word or short phrase that demonstrates the expected type of data, rather than an explanatory message. The text must...
Read more >
Error handling in a Javascript search function - Stack Overflow
I.e. I'd like to display another div with a message when the search comes up with no result and/or when the user makes...
Read more >
Handling operation errors - Apollo GraphQL Docs
Apollo Client helps you handle these errors according to their type, enabling you to show appropriate information to the user when an error...
Read more >
Improving TypeScript error handling with exhaustive type ...
Discover an improved method for handling errors in TypeScript that solves problems that arise from returning null and throwing try...catch.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found