Log result return or exception parameter. This method provides varied
        type of formatting based on the detail_level parameter and the
        data in ret.
436886
def stage_pywbem_result(self, ret, exc):
        
        def format_result(ret, max_len):
            """ format ret as repr while clipping it to max_len if
                max_len is not None.
            """
            # Format the 'summary' and 'paths' detail_levels
            if self.api_detail_level == 'summary':  # pylint: disable=R1705
                if isinstance(ret, list):
                    if ret:
                        ret_type = type(ret[0]).__name__ if ret else ""
                        return _format("list of {0}; count={1}",
                                       ret_type, len(ret))
                    return "Empty"

                ret_type = type(ret).__name__
                if hasattr(ret, 'classname'):
                    name = ret.classname
                elif hasattr(ret, 'name'):
                    name = ret.name
                else:
                    name = ""
                return _format("{0} {1}", ret_type, name)

            elif self.api_detail_level == 'paths':
                if isinstance(ret, list):
                    if ret:
                        if hasattr(ret[0], 'path'):
                            result_fmt = ', '.join(
                                [_format("{0!A}", str(p.path)) for p in ret])
                        else:
                            result_fmt = _format("{0!A}", ret)
                    else:
                        result_fmt = ''
                else:
                    if hasattr(ret, 'path'):
                        result_fmt = _format("{0!A}", str(ret.path))
                    else:
                        result_fmt = _format("{0!A}", ret)

            else:
                result_fmt = _format("{0!A}", ret)

            if max_len and (len(result_fmt) > max_len):
                result_fmt = result_fmt[:max_len] + '...'
            return result_fmt

        if self.enabled and self.api_detail_level is not None and \
                self.apilogger.isEnabledFor(logging.DEBUG):
            if exc:  # format exception
                # exceptions are always either all or reduced length
                result = format_result(
                    _format("{0}({1})", exc.__class__.__name__, exc),
                    self.api_maxlen)

                return_type = 'Exception'

            else:    # format result
                # test if type is tuple (subclass of tuple but not type tuple)
                # pylint: disable=unidiomatic-typecheck
                qrc = ""
                # format open/pull response
                if isinstance(ret, tuple) and \
                        type(ret) is not tuple:  # pylint: disable=C0123
                    try:    # test if field instances or paths
                        rtn_data = ret.instances
                        data_str = 'instances'
                    except AttributeError:
                        rtn_data = ret.paths
                        data_str = 'paths'

                    try:    # test for query_result_class
                        qrc = _format(
                            ", query_result_class={0}",
                            ret.query_result_class)
                    except AttributeError:
                        pass

                    result = _format(
                        "{0}(context={1}, eos={2}{3}, {4}={5})",
                        type(ret).__name__, ret.context, ret.eos, qrc,
                        data_str, format_result(rtn_data, self.api_maxlen))

                # format enumerate response except not open/pull
                elif isinstance(ret, list):
                    try:    # test for query_result_class
                        qrc = _format(
                            ", query_result_class={0}",
                            ret.query_result_class)
                    except AttributeError:
                        pass
                    ret_fmtd = format_result(ret, self.api_maxlen)
                    result = _format("{0}{1}", qrc, ret_fmtd)

                # format single return object
                else:
                    result = format_result(ret, self.api_maxlen)

                return_type = 'Return'

            self.apilogger.debug('%s:%s %s(%s)', return_type, self._conn_id,
                                 self._pywbem_method, result)
1244935
def result(retn):
    '''
    
    '''
    ok, valu = retn

    if ok:
        return valu

    name, info = valu

    ctor = getattr(s_exc, name, None)
    if ctor is not None:
        raise ctor(**info)

    info['errx'] = name
    raise s_exc.SynErr(**info)
985794
private function result()
    {
        // TODO: Call $this->onError(); hook

        // FIXME: Should be executed when exception is caught
        if (false) {
            // If not valid, return an error message to the tool consumer if a return URL is provided
            if (!empty($this->returnUrl)) {
                $error_url = $this->returnUrl;
                if (strpos($error_url, '?') === false) {
                    $error_url .= '?';
                } else {
                    $error_url .= '&';
                }
                if ($this->debugMode && !is_null($this->reason)) {
                    $error_url .= 'lti_errormsg=' . urlencode("Debug error: $this->reason");
                } else {
                    $error_url .= 'lti_errormsg=' . urlencode($this->message);
                    if (!is_null($this->reason)) {
                        $error_url .= '&lti_errorlog=' . urlencode("Debug error: $this->reason");
                    }
                }
                if (!is_null($this->consumer) && isset($_POST['lti_message_type']) && ($_POST['lti_message_type'] === 'ContentItemSelectionRequest')) {
                    $form_params = [];
                    if (isset($_POST['data'])) {
                        $form_params['data'] = $_POST['data'];
                    }
                    $version = (isset($_POST['lti_version'])) ? $_POST['lti_version'] : ToolProvider::LTI_VERSION1;
                    $form_params = $this->consumer->signParameters($error_url, 'ContentItemSelection', $version, $form_params);
                    $page = ToolProvider::sendForm($error_url, $form_params);
                    echo $page;
                } else {
                    header("Location: {$error_url}");
                }
                exit;
            } else {
                if (!is_null($this->errorOutput)) {
                    echo $this->errorOutput;
                } else if ($this->debugMode && !empty($this->reason)) {
                    echo "Debug error: {$this->reason}";
                } else {
                    echo "Error: {$this->message}";
                }
            }
        } else if (!is_null($this->redirectUrl)) {
            header("Location: {$this->redirectUrl}");
            exit;
        } else if (!is_null($this->output)) {
            echo $this->output;
        }
    }
171774
private String getDetails(Throwable error) {
		if (null == error) {
			return "";
		}
		StringBuilder content = new StringBuilder();
		content.append(error.getMessage());
		processStackTrace(error.getStackTrace(), content);
		content.append(getDetails(error.getCause()));
		return content.toString();
	}
481061
private String getDetails(ExceptionDto error) {
		if (null == error) {
			return "";
		}
		StringBuilder content = new StringBuilder();
		content.append(error.getClassName());
		if (error.getExceptionCode() != 0) {
			content.append(" (");
			content.append(error.getExceptionCode());
			content.append(")");
		}
		processStackTrace(error.getStackTrace(), content);
		content.append(getDetails(error.getCause()));
		return content.toString();
	}
400745
def display_results(results, detailed=False):
    
    # print("\nVALIDATOR RESULTS")
    # print("======================\n")

    if not detailed:
        print('FILENAME......................................... STATUS..........')

    for entry in results:
        try:
            if detailed:
                print("\n{}".format(entry["filename"]))
                print(create_detailed_results(entry))
            else:
                print("{:<50}{}".format(entry["filename"], entry["status"]))
        except Exception as e:
            logger_validator_api.debug("display_results: Exception: {}".format(e))
            print("Error: display_results: {}".format(e))

    return
832280
def formatException(self, record):
        
        if record.exc_info is None:
            return {}

        (exc_type, exc_message, trace) = record.exc_info

        return {
            'e': {
                'class': str(type(exc_type).__name__),  # ZeroDivisionError
                'message': str(exc_message),  # integer division or modulo by zero
                'trace': list(traceback.format_tb(trace)),
            }
        }
76533
def get_fields_for_exception(self, logger, exception):
        
        for klass in getmro(exception.__class__):
            if klass in self.registry:
                extractor = self.registry[klass]
                try:
                    return extractor(exception)
                except:
                    from ._traceback import write_traceback
                    write_traceback(logger)
                    return {}
        return {}
815415
def _format_exception(err, is_failure, stdout=None, stderr=None):
    """"""
    exctype, value, tb = err
    # Skip test runner traceback levels
    while tb and _is_relevant_tb_level(tb):
        tb = tb.tb_next

    if is_failure:
        # Skip assert*() traceback levels
        length = _count_relevant_tb_levels(tb)
        msgLines = traceback.format_exception(exctype, value, tb, length)
    else:
        msgLines = traceback.format_exception(exctype, value, tb)

    encoding = locale.getpreferredencoding()
    msgLines = [_decode(line, encoding) for line in msgLines]

    if stdout:
        if not stdout.endswith('\n'):
            stdout += '\n'
        msgLines.append(STDOUT_LINE % stdout)
    if stderr:
        if not stderr.endswith('\n'):
            stderr += '\n'
        msgLines.append(STDERR_LINE % stderr)
    return ''.join(msgLines)
163456
def result(self):
        """"""
        msg = "Use get_result() which forces correct exception handling"
        warnings.warn(DeprecationWarning(msg), stacklevel=2)
        return self._result
579524
public static boolean handleExceptionAndReturnFalse(Logger log,
            Throwable throwable, String method, Object... params) {
        handleException(log, throwable, method, params);
        return false;
    }
1194239
public static boolean log(Level level, Throwable t, String format, Object... arguments) {
		return log(LogFactory.get(CallerUtil.getCallerCaller()), level, t, format, arguments);
	}
222046
private int getReturnParam() {
    // look for [retval] attribute
        for (int i = 0; i < params.length; i++) {
      if (params[i].isRetval()) {
        return i;
      }
    }

    // sometimes a COM method has only one [out] param.
    // treat that as the return value.
    // this is seen frequently in MSHTML (see IHTMLChangeLog, for example)
    int outIdx = -1;
    for (int i = 0; i < params.length; i++) {
      if (params[i].isOut() && !params[i].isIn()) {
        if (outIdx == -1) {
          outIdx = i;
        } else {
          return -1; // more than one out. no return value
        }
      }
    }
    return outIdx;
  }
1301435
private void recursiveLogResult(StringBuilder buf, Hierarchy<Result> hier, Result result, int depth) {
    if(result == null) {
      buf.append("null");
      LOG.warning("null result!");
      return;
    }
    if(depth > 50) {
      LOG.warning("Probably infinitely nested results, aborting!");
      return;
    }
    for(int i = 0; i < depth; i++) {
      buf.append(' ');
    }
    buf.append(result.getClass().getSimpleName()).append(": ").append(result.getLongName()) //
        .append(" (").append(result.getShortName()).append(")\n");
    if(hier.numChildren(result) > 0) {
      for(It<Result> iter = hier.iterChildren(result); iter.valid(); iter.advance()) {
        recursiveLogResult(buf, hier, iter.get(), depth + 1);
      }
    }
  }
64008
def error_log(self, msg='', level=20, traceback=False):
        
        # Override this in subclasses as desired
        sys.stderr.write(msg + '\n')
        sys.stderr.flush()
        if traceback:
            tblines = traceback_.format_exc()
            sys.stderr.write(tblines)
            sys.stderr.flush()
278860
private void logErrorThrow(String format, Object... args) {
        String msg = MessageFormatter.arrayFormat(format, args).getMessage();
        m_logger.error(msg);
        throw new RuntimeException(msg);
    }
182468
public function logError(\Exception $e, $detailLevel = 1, $level = 1) {
    if ($detailLevel >= 5) {
      return $this->log("\n".'ERROR: '.\Psc\Exception::getExceptionText($e, 'text'));
    } else {
      return $this->log("\n".'ERROR: Exception: '.$e->getMessage(), $level);
    }
  }