~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-22 15:33:16 UTC
  • mto: This revision was merged to the branch mainline in revision 6404.
  • Revision ID: jelmer@samba.org-20111222153316-logw4b3xd4g1zqi7
Add ParseFormatError.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1170
1170
    def from_string(cls, text):
1171
1171
        format_string = cls.get_format_string()
1172
1172
        if not text.startswith(format_string):
1173
 
            raise ValueError("Invalid format header %r" % text)
 
1173
            raise AssertionError("Invalid format header %r for %r" % (text, cls))
1174
1174
        lines = text[len(format_string):].splitlines()
1175
1175
        ret = cls()
1176
1176
        for lineno, line in enumerate(lines):
1177
 
            (necessity, feature) = line.split(" ", 1)
 
1177
            try:
 
1178
                (necessity, feature) = line.split(" ", 1)
 
1179
            except ValueError:
 
1180
                raise errors.ParseFormatError(format=cls, lineno=lineno+2,
 
1181
                    line=line, text=text)
1178
1182
            ret.features[feature] = necessity
1179
1183
        return ret
1180
1184