protected function getErrorDetails(\Exception $e, $trace = false)
    {
        $msg = $e->getMessage();
        if ($e instanceof DfException) {
            $context = $e->getContext();
            if (is_array($context)) {
                $context = print_r($context, true);
            }
            if (!empty($context)) {
                $msg .= "\nContext: " . $context;
            }
        }

        if ($trace === true) {
            $msg .= "\nTrace:\n" . $e->getTraceAsString();
        }

        return $msg;
    }