-
Notifications
You must be signed in to change notification settings - Fork 853
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
Conversation
…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>
…ll-result-with-external-error
…:arangodb/arangodb into feature/error-messages-as-string-views
There was a problem hiding this 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.
arangod/Aql/QueryWarnings.cpp
Outdated
@@ -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()); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is data
null-terminated?
arangod/Aql/Parser.cpp
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
…or-messages-as-string-views
…or-messages-as-string-views
…or-messages-as-string-views
8ea6619
to
7463f85
Compare
Co-authored-by: Jan <jsteemann@users.noreply.github.com>
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 asstd::string_view
s instead ofchar const*
.Enterprise companion PR: https://github.com/arangodb/enterprise/pull/641
Backports:
Testing & Verification
(Please pick either of the following options)