Repository: conan-io/conan
Pull request: Handle unknown statement while parsing profile. Fixes #6931
Changelog: Bugfix: Provide a more descriptive error when an unknown statement is added to a profile
Docs: omit

Closes: #6931

Tested with the example provided in the [examples repository](https://github.com/conan-io/examples/tree/master/features/emscripten)

I replaced the first line:
```
include(default)
```

By:
```
includes(default)
```

When running `conan` before this change, the command output is:
```sh
✗ ./build.sh
+ conan remove 'conan-hello-emscripten/*' -f
WARN: No package recipe matches 'conan-hello-emscripten/*'
+ conan create . conan/testing -pr emscripten.profile --build missing
ERROR: Error reading 'emscripten.profile' profile: Error parsing the profile text file: not enough values to unpack (expected 2, got 1)
```

After this change:
```sh
✗ ./build.sh
+ conan remove 'conan-hello-emscripten/*' -f
WARN: No package recipe matches 'conan-hello-emscripten/*'
+ conan create . conan/testing -pr emscripten.profile --build missing
ERROR: Error reading 'emscripten.profile' profile: Error while parsing line 0: 'includes(default)'
```

Problem statement:
[feature] Confusing error message when typo in profile
I had a typo in my profile file:

```
includes(cmake_3_16)

[build_requires]
doxygen/1.8.15@company/stable
```

Where it should have been `include` instead of `includes`. 
When running Conan, I got the following error message:

```
ERROR: Error reading 'documentation' profile: Error parsing the profile text file: not enough values to unpack (expected 2, got 1)
```

At least I knew that something is wrong with the profile, but the error message was a bit misleading
A more helpful message could have been:

```
ERROR: Error reading 'documentation' profile: Error parsing the profile text file: includes is not a valid keyword
```
or something similar.

### Environment Details (include every applicable attribute)
  * Conan version: 1.24.1

Hints from issue discussion:
Thanks for reporting it. I think it should be easy to identify this error and provide a better message. Thanks!

Commit message: Handle unknown statement while parsing profile. Fixes #6931

Patch to review:
diff --git a/conans/client/profile_loader.py b/conans/client/profile_loader.py
index 431dbad2965..21c8193eb26 100644
--- a/conans/client/profile_loader.py
+++ b/conans/client/profile_loader.py
@@ -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
@@ -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))
                 name = name.strip()
                 if " " in name:
                     raise ConanException("The names of the variables cannot contain spaces")
diff --git a/conans/errors.py b/conans/errors.py
index 7df260b82f0..10517669ce7 100644
--- a/conans/errors.py
+++ b/conans/errors.py
@@ -136,6 +136,10 @@ class ConanConnectionError(ConanException):
     pass
 
 
+class ConanParsingError(ConanException):
+    pass
+
+
 class ConanOutdatedClient(ConanException):
     pass
 


Code review comments:
diff_hunk: @@ -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))
path: conans/client/profile_loader.py
text: @user1:
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.