8000 Feature/error messages as string views by goedderz · Pull Request #13455 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Feature/error messages as string views #13455

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

Merged
merged 66 commits into from
Feb 11, 2021

Conversation

goedderz
Copy link
Member
@goedderz goedderz commented Jan 27, 2021

Scope & Purpose

As the length of error messages (as returned by TRI_errno_string) is known at compile time, it makes sense to save and return them as std::string_views instead of char const*.

  • 💩 Bugfix (requires CHANGELOG entry)
  • 🍕 New feature (requires CHANGELOG entry, feature documentation and release notes)
  • 🔥 Performance improvement
  • 🔨 Refactoring/simplification
  • 📖 CHANGELOG entry made

Enterprise companion PR: https://github.com/arangodb/enterprise/pull/641

Backports:

  • No backports required
  • Backports required for: (Please specify versions and link PRs)

Testing & Verification

(Please pick either of the following options)

  • This change is a trivial rework / code cleanup without any test coverage.
  • The behavior in this PR was manually tested
  • This change is already covered by existing tests, such as scripts/unittest.
  • This PR adds tests that were used to verify all changes:
    • Added new C++ Unit tests
    • Added new integration tests (e.g. in shell_server / shell_server_aql)
    • Added new resilience tests (only if the feature is impacted by failovers)
  • There are tests in an external testing repository:
  • I ensured this code runs with ASan / TSan or other static verification tools

goedderz and others added 30 commits January 21, 2021 15:10
…b/arangodb into feature/small-result-with-external-error
…om:arangodb/arangodb into feature/small-result-with-external-error
…om:arangodb/arangodb into feature/small-result-with-external-error
…om:arangodb/arangodb into feature/small-result-with-external-error
…b/arangodb into feature/refactor-error-message-string-view
…om:arangodb/arangodb into feature/small-result-with-external-error
Co-authored-by: Jan <jsteemann@users.noreply.github.com>
…:arangodb/arangodb into feature/error-messages-as-string-views
@goedderz
Copy link
Member Author
goedderz commented Feb 5, 2021

image

@goedderz goedderz marked this pull request as ready for review February 5, 2021 06:42
Copy link
Contributor
@maierlars maierlars left a comment

Choose a reason for hiding this comment

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

std::string_view::data() does not return a null-terminated string.

@@ -53,6 +53,10 @@ void QueryWarnings::registerWarning(int code, std::string const& details) {
registerWarning(code, details.c_str());
}

void QueryWarnings::registerWarning(int code, std::string_view details) {
registerWarning(code, details.data());
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if registerWarning expects the string to be null-terminated but data from a string is not necessarily null-terminated.

@@ -176,7 +181,7 @@ void Parser::registerParseError(int errorCode, char const* data, int line, int c
}

/// @brief register a warning
void Parser::registerWarning(int errorCode, char const* data, int line, int column) {
void Parser::registerWarning(int errorCode, std::string_view data, int line, int column) {
// ignore line and column for now
_query.warnings().registerWarning(errorCode, data);
Copy link
Contributor

Choose a reason for hiding this comment

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

is data null-terminated?

@@ -144,6 +144,11 @@ void Parser::registerParseError(int errorCode, char const* format,
return registerParseError(errorCode, buffer, line, column);
}

void Parser::registerParseError(int errorCode, std::string_view format,
char const* data, int line, int column) {
return registerParseError(errorCode, format.data(), data, line, column);
Copy link
Contributor

Choose a reason for hiding this comment

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

data() is not null-terminated in general.

@goedderz
Copy link
Member Author

@goedderz
Copy link
Member Author

@goedderz
Copy link
Member Author

image

@goedderz goedderz force-pushed the feature/error-messages-as-string-views branch from 8ea6619 to 7463f85 Compare February 11, 2021 08:09
@goedderz
Copy link
Member Author

@jsteemann jsteemann merged commit 389342f into devel Feb 11, 2021
@jsteemann jsteemann deleted the feature/error-messages-as-string-views branch February 11, 2021 13:19
elfringham pushed a commit to elfringham/arangodb that referenced this pull request Apr 20, 2021
Co-authored-by: Jan <jsteemann@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0