public static function fromPrevious($id, \Exception $prev = null)
    {
        $message = strtr(static::$template, array(
            '{id}'    => (is_string($id) || method_exists($id, '__toString')) ? $id : '?',
            '{error}' => $prev ? get_class($prev) : 'error',
        ));

        if ($prev) {
            $message .= ' Message: ' . $prev->getMessage();
        }

        return new static($message, 0, $prev);
    }