Repository: conan-io/conan
Pull request: Fix exit code for conan_build_info
Changelog: Bugfix: Fix exit code for `conan_build_info`.
Docs: omit

Fixes: https://github.com/conan-io/conan/issues/8395

- [X] Refer to the issue that supports this Pull Request.
- [X] If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
- [X] I've read the [Contributing guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).
- [X] I've followed the PEP8 style guides for Python code.
- [ ] I've opened another PR in the Conan docs repo to the ``develop`` branch, documenting this one. 

<sup>**Note:** By default this PR will skip the slower tests and will use a limited set of python versions. Check [here](https://github.com/conan-io/conan/blob/develop/.github/PR_INCREASE_TESTING.md) how to increase the testing level by writing some tags in the current PR body text.</sup>


Problem statement:
[bug] conan_build_info does not raise in event of an error
Failure to publish buildinfo in one of our CI jobs went undetected because an error occurred but was not raised.

### Environment Details (include every applicable attribute)
  * Operating System+version: Windows 10 64-bit
  * Compiler+version: n/a
  * Conan version: 1.33.0
  * Python version: 3.7.3

### Steps to reproduce (Include if Applicable)
Try to publish erroneous buildinfo to artifactory.  In my case the 'properties' section contained an Ã character from the gerrit-injected env var for commit message (which I wasn't aware is not supported).

### Logs (Executed commands with output) (Include/Attach if Applicable)
```
conan_build_info --v2 publish buildinfo.json --url=<artifactory url> --user=**** --password=**** 
[1m[31mERROR: 'latin-1' codec can't encode character '\u201a' in position 3538: ordinal not in range(256)[0m
```

<!--
  Your log content should be related to the bug description, it can be:
  - Conan command output
  - Server output (Artifactory, conan_server)
-->

Hints from issue discussion:
Hi @GordonJess,
Thanks a lot for reporting, you are right the exit code of `conan_build_info` was not correctly applied.
Will be fixed as soon as possible.

Commit message: exit 1 when error

Patch to review:
diff --git a/conans/build_info/command.py b/conans/build_info/command.py
index 20dcc74598d..5bc40ead8cd 100644
--- a/conans/build_info/command.py
+++ b/conans/build_info/command.py
@@ -121,10 +121,9 @@ def check_credential_arguments():
             check_credential_arguments()
             publish_build_info(args.buildinfo, args.url, args.user, args.password,
                                args.apikey)
-    except ConanException as exc:
-        output.error(exc)
     except Exception as exc:
         output.error(exc)
+        exit(1)
 
 
 if __name__ == "__main__":


Code review comments:
diff_hunk: @@ -121,10 +121,9 @@ def check_credential_arguments():
             check_credential_arguments()
             publish_build_info(args.buildinfo, args.url, args.user, args.password,
                                args.apikey)
-    except ConanException as exc:
-        output.error(exc)
     except Exception as exc:
         output.error(exc)
+        exit(1)
path: conans/build_info/command.py
text: @user1:
Use sys.exit() instead