def format(self):
        """Return a formatted error message from all the gathered errors.
        """
        indent = ' ' * self._scale
        argstr = argsnkwargs_to_str(self._args, self._kwargs)
        ncandidates = sum([len(x) for x in self._failures.values()])

        # sort out a display name for the function
        tykey = self._function_type.typing_key
        # most things have __name__
        fname = getattr(tykey, '__name__', None)
        is_external_fn_ptr = isinstance(self._function_type,
                                        ExternalFunctionPointer)

        if fname is None:
            if is_external_fn_ptr:
                fname = "ExternalFunctionPointer"
            else:
                fname = "<unknown function>"

        msgbuf = [_header_template.format(the_function=self._function_type,
                                          fname=fname,
                                          signature=argstr,
                                          ncandidates=ncandidates)]
        nolitargs = tuple([unliteral(a) for a in self._args])
        nolitkwargs = {k: unliteral(v) for k, v in self._kwargs.items()}
        nolitargstr = argsnkwargs_to_str(nolitargs, nolitkwargs)

        # depth could potentially get massive, so limit it.
        ldepth = min(max(self._depth, 0), self._max_depth)

        def template_info(tp):
            src_info = tp.get_template_info()
            unknown = "unknown"
            source_name = src_info.get('name', unknown)
            source_file = src_info.get('filename', unknown)
            source_lines = src_info.get('lines', unknown)
            source_kind = src_info.get('kind', 'Unknown template')
            return source_name, source_file, source_lines, source_kind

        for i, (k, err_list) in enumerate(self._failures.items()):
            err = err_list[0]
            nduplicates = len(err_list)
            template, error = err.template, err.error
            ifo = template_info(template)
            source_name, source_file, source_lines, source_kind = ifo
            largstr = argstr if err.literal else nolitargstr

            if err.error == "No match.":
                err_dict = defaultdict(set)
                for errs in err_list:
                    err_dict[errs.template].add(errs.literal)
                # if there's just one template, and it's erroring on
                # literal/nonliteral be specific
                if len(err_dict) == 1:
                    template = [_ for _ in err_dict.keys()][0]
                    source_name, source_file, source_lines, source_kind = \
                        template_info(template)
                    source_lines = source_lines[0]
                else:
                    source_file = "<numerous>"
                    source_lines = "N/A"

                msgbuf.append(_termcolor.errmsg(
                    _wrapper(_overload_template.format(nduplicates=nduplicates,
                                                       kind=source_kind.title(),
                                                       function=fname,
                                                       inof='of',
                                                       file=source_file,
                                                       line=source_lines,
                                                       args=largstr),
                             ldepth + 1)))
                msgbuf.append(_termcolor.highlight(_wrapper(err.error,
                                                            ldepth + 2)))
            else:
                # There was at least one match in this failure class, but it
                # failed for a specific reason try and report this.
                msgbuf.append(_termcolor.errmsg(
                    _wrapper(_overload_template.format(nduplicates=nduplicates,
                                                       kind=source_kind.title(),
                                                       function=source_name,
                                                       inof='in',
                                                       file=source_file,
                                                       line=source_lines[0],
                                                       args=largstr),
                             ldepth + 1)))

                if isinstance(error, BaseException):
                    reason = indent + self.format_error(error)
                    errstr = _err_reasons['specific_error'].format(reason)
                else:
                    errstr = error
                # if you are a developer, show the back traces
                if config.DEVELOPER_MODE:
                    if isinstance(error, BaseException):
                        # if the error is an actual exception instance, trace it
                        bt = traceback.format_exception(type(error), error,
                                                        error.__traceback__)
                    else:
                        bt = [""]
                    bt_as_lines = _bt_as_lines(bt)
                    nd2indent = '\n{}'.format(2 * indent)
                    errstr += _termcolor.reset(nd2indent +
                                               nd2indent.join(bt_as_lines))
                msgbuf.append(_termcolor.highlight(_wrapper(errstr,
                                                            ldepth + 2)))
                loc = self.get_loc(template, error)
                if loc:
                    msgbuf.append('{}raised from {}'.format(indent, loc))

        # the commented bit rewraps each block, may not be helpful?!
        return _wrapper('\n'.join(msgbuf) + '\n') # , self._scale * ldepth)
Return a formatted error message from all the gathered errors.
        
numba/core/types/functions.py