class error_with_option_name

Declaration

class error_with_option_name : public error { /* full declaration omitted */ };

Description

Base class for most exceptions in the library. Substitutes the values for the parameter name placeholders in the template to create the human readable error message Placeholders are surrounded by % signs: %example% Poor man's version of boost::format If a parameter name is absent, perform default substitutions instead so ugly placeholders are never left in-place. Options are displayed in "canonical" form This is the most unambiguous form of the *parsed* option name and would correspond to option_description::format_name() i.e. what is shown by print_usage() The "canonical" form depends on whether the option is specified in short or long form, using dashes or slashes or without a prefix (from a configuration file)

Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:103

Inherits from: error

Member Variables

protected int m_option_style
can be 0 = no prefix (config file options) allow_long allow_dash_for_short allow_slash_for_short allow_long_disguise
protected std::map<std::string, std::string> m_substitutions
substitutions from placeholders to values
protected std::map<std::string, string_pair> m_substitution_defaults
public std::string m_error_template
template with placeholders
protected std::string m_message
Used to hold the error text returned by what()

Method Overview

Inherited from error:

    Methods

    void add_context(
        const std::string& option_name,
        const std::string& original_token,
        int option_style)

    Description

    Add context to an exception

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:152

    Parameters

    const std::string& option_name
    const std::string& original_token
    int option_style

    error_with_option_name(
        const std::string& template_,
        const std::string& option_name = "",
        const std::string& original_token = "",
        int option_style = 0)

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:124

    Parameters

    const std::string& template_
    const std::string& option_name = ""
    const std::string& original_token = ""
    int option_style = 0

    std::string get_canonical_option_name() const

    Description

    Construct option name in accordance with the appropriate prefix style: i.e. long dash or short slash etc

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:200

    std::string get_canonical_option_prefix() const

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:201

    std::string get_option_name() const

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:172

    void replace_token(const std::string& from,
                       const std::string& to) const

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:195

    Parameters

    const std::string& from
    const std::string& to

    virtual void set_option_name(
        const std::string& option_name)

    Description

    Overridden in error_with_no_option_name

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:167

    Parameters

    const std::string& option_name

    void set_original_token(
        const std::string& original_token)

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:177

    Parameters

    const std::string& original_token

    void set_prefix(int option_style)

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:161

    Parameters

    int option_style

    void set_substitute(
        const std::string& parameter_name,
        const std::string& value)

    Description

    Substitute parameter_name->value to create the error message from the error template

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:136

    Parameters

    const std::string& parameter_name
    const std::string& value

    void set_substitute_default(
        const std::string& parameter_name,
        const std::string& from,
        const std::string& to)

    Description

    If the parameter is missing, then make the from->to substitution instead

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:144

    Parameters

    const std::string& parameter_name
    const std::string& from
    const std::string& to

    virtual void substitute_placeholders(
        const std::string& error_template) const

    Description

    Makes all substitutions using the template

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:191

    Parameters

    const std::string& error_template

    const char* what() const noexcept

    Description

    Creates the error_message on the fly Currently a thin wrapper for substitute_placeholders()

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:184

    ~error_with_option_name() noexcept

    Description

    gcc says that throw specification on dtor is loosened without this line

    Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:131