Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle unknown statement while parsing profile. Fixes #6931 #7577

Merged
merged 5 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions conans/client/profile_loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from collections import OrderedDict, defaultdict

from conans.errors import ConanException, ConanV2Exception
from conans.errors import ConanException, ConanV2Exception, ConanParsingError
from conans.model.env_info import EnvValues, unquote
from conans.model.options import OptionsValues
from conans.model.profile import Profile
Expand Down Expand Up @@ -38,7 +38,10 @@ def __init__(self, text):
include = include[:-1]
self.includes.append(include)
else:
name, value = line.split("=", 1)
try:
name, value = line.split("=", 1)
except ValueError as error:
raise ConanParsingError("Error while parsing line %i: '%s'" % (counter, line))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's throw a generic ConanException. New exceptions will be introduced from now on, only if it is going to be captured and processed somewhere else. Let's keep it simple.

name = name.strip()
if " " in name:
raise ConanException("The names of the variables cannot contain spaces")
Expand Down
4 changes: 4 additions & 0 deletions conans/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class ConanConnectionError(ConanException):
pass


class ConanParsingError(ConanException):
pass


class ConanOutdatedClient(ConanException):
pass

Expand Down