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.

StringMap to handle missing keys instead of throwing an exception

See original GitHub issue

Issue Description

StringIndexerModel has the property handleInvalid with possible values:

  • error
  • skip
  • keep

StringMap doesn’t currently have such property. It always throws an exception if the key is missing in StringMapModel.labels, so it’s currently “always handleInvalid=error”.

Would you be ok with adding the same property to StringMap? If you like, I can make a pull request.

In StringMap’s case I think there should be an additional parameter to specify the default value.

Issue Analytics

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

github_iconTop GitHub Comments

ancasarbcommented, Sep 4, 2019

@juhoautio we don’t hardcode the attributes for each of the transformers, they’re all part of the Attributes map, you can take a look and

ancasarbcommented, Sep 15, 2019

PR has been merged, closing issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is benefit of not raising error (like Python) when key is ...
Go does not raise errors. Go reports errors. A common use of a map element zero value:
Read more >
How to Check If a Key Exists in a Map | Baeldung
Learn how to check if a key exists in a Map in Java and a common pitfall.
Read more >
Handling missing keys in Python dictionaries - GeeksforGeeks
In python, dictionaries are containers that map one key to its value with access time complexity to be O(1). But in many applications, ......
Read more >
Java Map Introduction
A map stores key/value pairs, where each key has an associated value. Given a particular key, the map can look up the associated...
Read more >
Map key-not-found (null vs exception) - Google Groups
Map[key] returns null if key is not in the map. It could instead throw an exception, consistent with collections such as List and...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found