# Path: rebasehelper/exceptions.py
# class RebaseHelperError(Exception):
#     """Class representing Error raised inside rebase-helper after intentionally
#     catching some expected and well known exception/error.
# 
#     """
# 
#     def __init__(self, *args, **kwargs):
#         """Constructor of RebaseHelperError"""
#         super().__init__()
#         if not args:
#             self.msg = None
#         elif len(args) > 1:
#             self.msg = args[0] % args[1:]
#         else:
#             self.msg = args[0]
#         self.logfiles = kwargs.get('logfiles')
# 
#     def __str__(self):
#         return str(self.msg) if self.msg else ''
# 
# class ParseError(Exception):
#     pass


import argparse
import sys
from rebasehelper.exceptions import RebaseHelperError, ParseError
        elif self.append:
            value = getattr(namespace, self.dest, [])
            value.extend(values)
        elif self.switch:
            value = True
        else:
            value = values
        setattr(namespace, self.dest, value)


class CustomArgumentParser(argparse.ArgumentParser):

    def _check_value(self, action, value):
        if isinstance(value, list):
            # converted value must be subset of the choices (if specified)
            empty = value == action.const
            if action.choices is not None and not empty and not set(value).issubset(action.choices):
                invalid = set(value).difference(action.choices)
                if len(invalid) == 1:
                    tup = repr(invalid.pop()), ', '.join(map(repr, action.choices))
                    msg = 'invalid choice: %s (choose from %s)' % tup
                else:
                    tup = ', '.join(map(repr, invalid)), ', '.join(map(repr, action.choices))
                    msg = 'invalid choices: %s (choose from %s)' % tup
                raise argparse.ArgumentError(action, msg)
        else:
            super()._check_value(action, value)

    def error(self, message):
        self.print_usage(sys.stderr)

# Path: rebasehelper/exceptions.py
# class RebaseHelperError(Exception):
#     """Class representing Error raised inside rebase-helper after intentionally
#     catching some expected and well known exception/error.
# 
#     """
# 
#     def __init__(self, *args, **kwargs):
#         """Constructor of RebaseHelperError"""
#         super().__init__()
#         if not args:
#             self.msg = None
#         elif len(args) > 1:
#             self.msg = args[0] % args[1:]
#         else:
#             self.msg = args[0]
#         self.logfiles = kwargs.get('logfiles')
# 
#     def __str__(self):
#         return str(self.msg) if self.msg else ''
# 
# class ParseError(Exception):
#     pass


# Path: rebasehelper/argument_parser.py
import argparse
import sys
from rebasehelper.exceptions import RebaseHelperError, ParseError

        elif self.append:
            value = getattr(namespace, self.dest, [])
            value.extend(values)
        elif self.switch:
            value = True
        else:
            value = values
        setattr(namespace, self.dest, value)


class CustomArgumentParser(argparse.ArgumentParser):

    def _check_value(self, action, value):
        if isinstance(value, list):
            # converted value must be subset of the choices (if specified)
            empty = value == action.const
            if action.choices is not None and not empty and not set(value).issubset(action.choices):
                invalid = set(value).difference(action.choices)
                if len(invalid) == 1:
                    tup = repr(invalid.pop()), ', '.join(map(repr, action.choices))
                    msg = 'invalid choice: %s (choose from %s)' % tup
                else:
                    tup = ', '.join(map(repr, invalid)), ', '.join(map(repr, action.choices))
                    msg = 'invalid choices: %s (choose from %s)' % tup
                raise argparse.ArgumentError(action, msg)
        else:
            super()._check_value(action, value)

    def error(self, message):
        self.print_usage(sys.stderr)

        raise RebaseHelperError(message)