Skip to content

get_bool raises a different Exception than the other getters when key is missing #135

@movermeyer

Description

@movermeyer

The following code:

from pyhocon import ConfigFactory
config = ConfigFactory.parse_string("")

for getter in [config.get, config.get_string, config.get_list, config.get_int, config.get_float, config.get_config, config.get_bool]:
    try:
        getter("missing_value")
    except Exception as exc:
        print str(getter), type(exc)
        print "\t", exc

produces the following output:

<bound method ConfigTree.get of ConfigTree()> <class 'pyhocon.exceptions.ConfigMissingException'>
        u'No configuration setting found for key missing_value'
<bound method ConfigTree.get_string of ConfigTree()> <class 'pyhocon.exceptions.ConfigMissingException'>
        u'No configuration setting found for key missing_value'
<bound method ConfigTree.get_list of ConfigTree()> <class 'pyhocon.exceptions.ConfigMissingException'>
        u'No configuration setting found for key missing_value'
<bound method ConfigTree.get_int of ConfigTree()> <class 'pyhocon.exceptions.ConfigMissingException'>
        u'No configuration setting found for key missing_value'
<bound method ConfigTree.get_float of ConfigTree()> <class 'pyhocon.exceptions.ConfigMissingException'>
        u'No configuration setting found for key missing_value'
<bound method ConfigTree.get_config of ConfigTree()> <class 'pyhocon.exceptions.ConfigMissingException'>
        u'No configuration setting found for key missing_value'
<bound method ConfigTree.get_bool of ConfigTree()> <class 'pyhocon.exceptions.ConfigException'>
        missing_value does not translate to a Boolean value

All the "getters", except get_bool, raise pyhocon.exceptions.ConfigMissingException, while get_bool raises pyhocon.exceptions.ConfigException.

This bug/inconsistency was introduced in the change from 0.3.35 -> 0.3.36.
Tested with Python 2.7.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions