public static function getExceptionNameHierarchy(\Exception $e, $separator = ' >> ')
    {
        $names = array();

        // Loop through the exception hierarchy until there is no previous
        // exception and store the class names of each found exception in the
        // $names array.
        do {
            $names[] = get_class($e);
        } while (($e = $e->getPrevious()) !== null);

        // Concatenate the exception name with the separator.
        $names = implode($separator, $names);

        return $names;
    }