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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
3e30055
Made Result contain only an optional pointer to an error
goedderz Jan 21, 2021
fd78e02
Fixed compile error
goedderz Jan 21, 2021
df2e43c
Avoid no-error allocations
goedderz Jan 21, 2021
d447876
WIP
goedderz Jan 25, 2021
4d8d9b1
WIP
goedderz Jan 25, 2021
ab77f45
Added concatT and joinT to StringUtils
goedderz Jan 25, 2021
331fad5
Fixed tests
goedderz Jan 25, 2021
bfc7901
Merge branch 'feature/string-utils-concat-join' of github.com:arangod…
goedderz Jan 25, 2021
699a5dc
Changed namespace from impl to detail
goedderz Jan 25, 2021
8aa96ae
Assert capacity
goedderz Jan 25, 2021
b0e1b0c
Fixed compile errors
goedderz Jan 25, 2021
83bb4f8
Return a string_view in Result::errorMessage
goedderz Jan 25, 2021
c2435bc
Removed erroneous line
goedderz Jan 25, 2021
6949f89
Merge branch 'feature/refactor-error-message-string-view' of github.c…
goedderz Jan 25, 2021
0fed08d
Fixed some compile errors
goedderz Jan 26, 2021
d91cfb5
Some minor changes
goedderz Jan 26, 2021
6eb6ee1
Merge branch 'feature/refactor-error-message-string-view' of github.c…
goedderz Jan 26, 2021
1956b21
Update lib/Basics/ResultT.h
goedderz Jan 26, 2021
f5de874
Merge branch 'feature/refactor-error-message-string-view' of github.c…
goedderz Jan 26, 2021
84511fb
Fixed Mac compile error
goedderz Jan 26, 2021
eaacdc0
Merge branch 'feature/string-utils-concat-join' of github.com:arangod…
goedderz Jan 26, 2021
d988cf8
Merge branch 'feature/refactor-error-message-string-view' of github.c…
goedderz Jan 26, 2021
6d83aeb
Update lib/Basics/Result.h
goedderz Jan 27, 2021
937877d
Added errorMessage move overloads
goedderz Jan 27, 2021
4d49f20
Added noexcept where mentioned in reviews
goedderz Jan 27, 2021
0e098b2
Be consistent.
goedderz Jan 27, 2021
9c209b3
Merge branch 'devel' of github.com:arangodb/arangodb into feature/sma…
goedderz Jan 27, 2021
95e21c9
Make TRI_errno_string return a string_view
goedderz Jan 27, 2021
9e25112
Removed superfluous lines
goedderz Jan 27, 2021
2e6b197
Merge branch 'feature/small-result-with-external-error' of github.com…
goedderz Jan 27, 2021
6b15b7e
Fixed compile errors due to previous change
goedderz Jan 27, 2021
bc3c0ef
Merge branch 'devel' of github.com:arangodb/arangodb into feature/sma…
goedderz Jan 27, 2021
27fb946
Fixed merge conflict
goedderz Jan 27, 2021
0433a27
Minor changes
goedderz Jan 27, 2021
0fa6aa1
Added some assertions
goedderz Jan 28, 2021
76f2312
Pass conflictingDocumentKey separately, no longer in a Result's error…
goedderz Jan 28, 2021
99d1190
Merge branch 'feature/small-result-with-external-error' of github.com…
goedderz Jan 28, 2021
690c2d7
Fixed prior commit
goedderz Jan 28, 2021
f816181
Fix compile error
goedderz Jan 29, 2021
68be618
Merge branch 'feature/small-result-with-external-error' of github.com…
goedderz Jan 29, 2021
a6e7b67
Fixed assertion
goedderz Jan 29, 2021
943bf3e
Fix
goedderz Feb 1, 2021
e928f04
Only return conflicting key when it's meaningful, to soothe an assertion
goedderz Feb 1, 2021
0d78b83
Reformat
goedderz Feb 1, 2021
ef30942
Added a comment
goedderz Feb 1, 2021
a29e7bd
Addressed review comments
goedderz Feb 1, 2021
054cd6d
Merge branch 'feature/small-result-with-external-error' of github.com…
goedderz Feb 1, 2021
8d8bd19
Merge commit '0737c305c536043a3cde5916957dd2714836d25f' into feature/…
goedderz Feb 2, 2021
6fe7d1b
Merge branch 'devel' of github.com:arangodb/arangodb into feature/err…
goedderz Feb 2, 2021
3900256
Fix va args call in macro
goedderz Feb 3, 2021
9c4335f
autoformat
goedderz Feb 3, 2021
29239a0
Try not to rely on error messages being null-terminated as much as po…
goedderz Feb 3, 2021
6759548
Removed unused parts in exitcodes
goedderz Feb 3, 2021
5b2e94f
Try to fix conversion error on windows
goedderz Feb 3, 2021
0161341
Reverted two changes, fixed a compile error, fixed an off-by-one
goedderz Feb 4, 2021
61b16ff
Added a comment
goedderz Feb 4, 2021
d83d7b7
Merge branch 'devel' of github.com:arangodb/arangodb into feature/err…
goedderz Feb 8, 2021
b4f9613
Adressed some review comments
goedderz Feb 8, 2021
c8021d0
Passed some more errors as string_views
goedderz Feb 8, 2021
4dfcda5
Merge branch 'devel' of github.com:arangodb/arangodb into feature/err…
goedderz Feb 10, 2021
62f8892
Removed merge conflict marker
goedderz Feb 10, 2021
c768295
Fixed merge conflicts
goedderz Feb 10, 2021
baf963f
Fixed erroneous argument to snprintf
goedderz Feb 10, 2021
7463f85
Merge branch 'devel' of github.com:arangodb/arangodb into feature/err…
goedderz Feb 11, 2021
55dd841
Fixed merge conflict
goedderz Feb 11, 2021
72b9738
Removed voc-errors.cpp
goedderz Feb 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'devel' of github.com:arangodb/arangodb into feature/err…
…or-messages-as-string-views
  • Loading branch information
goedderz committed Feb 10, 2021
commit 4dfcda5e7101db45c5ad8d98bfbbca61701c4626
6 changes: 3 additions & 3 deletions arangod/Aql/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ QueryResult Parser::parseWithDetails() {
}

/// @brief register a parse error, position is specified as line / column
void Parser::registerParseError(int errorCode, char const* format,
void Parser::registerParseError(ErrorCode errorCode, char const* format,
std::string_view data, int line, int column) {
char buffer[512];
// make sure the buffer is always initialized
Expand All @@ -145,7 +145,7 @@ void Parser::registerParseError(int errorCode, char const* format,
}

/// @brief register a parse error, position is specified as line / column
void Parser::registerParseError(int errorCode, std::string_view data, int line, int column) {
void Parser::registerParseError(ErrorCode errorCode, std::string_view data, int line, int column) {
TRI_ASSERT(errorCode != TRI_ERROR_NO_ERROR);
TRI_ASSERT(data.data() != nullptr);

Expand Down Expand Up @@ -176,7 +176,7 @@ void Parser::registerParseError(int errorCode, std::string_view data, int line,
}

/// @brief register a warning
void Parser::registerWarning(int errorCode, std::string_view data,
void Parser::registerWarning(ErrorCode errorCode, std::string_view data,
[[maybe_unused]] int line, [[maybe_unused]] 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?

Expand Down
9 changes: 5 additions & 4 deletions arangod/Aql/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ class Parser {
QueryResult parseWithDetails();

/// @brief register a parse error, position is specified as line / column
void registerParseError(int, char const*, std::string_view, int, int);
void registerParseError(ErrorCode errorCode, char const* format,
std::string_view data, int line, int column);

/// @brief register a parse error, position is specified as line / column
void registerParseError(int, std::string_view, int, int);
void registerParseError(ErrorCode errorCode, std::string_view data, int line, int column);

/// @brief register a warning
void registerWarning(int, std::string_view, int, int);
void registerWarning(ErrorCode errorCode, std::string_view data, int line, int column);

/// @brief push an AstNode array element on top of the stack
/// the array must be removed from the stack via popArray
Expand Down
4 changes: 2 additions & 2 deletions arangod/Aql/QueryWarnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ QueryWarnings::QueryWarnings()

/// @brief register an error
/// this also makes the query abort
void QueryWarnings::registerError(int code, std::string_view details) {
void QueryWarnings::registerError(ErrorCode code, std::string_view details) {
TRI_ASSERT(code != TRI_ERROR_NO_ERROR);

if (details.data() == nullptr) {
Expand All @@ -50,7 +50,7 @@ void QueryWarnings::registerError(int code, std::string_view details) {
}

/// @brief register a warning
void QueryWarnings::registerWarning(int code, std::string_view details) {
void QueryWarnings::registerWarning(ErrorCode code, std::string_view details) {
TRI_ASSERT(code != TRI_ERROR_NO_ERROR);

std::lock_guard<std::mutex> guard(_mutex);
Expand Down
5 changes: 2 additions & 3 deletions arangod/Aql/QueryWarnings.h
8000
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ class QueryWarnings final {

/// @brief register an error
/// this also makes the query abort
[[noreturn]] void registerError(int, std::string_view = {});

[[noreturn]] void registerError(ErrorCode code, std::string_view details = nullptr);
/// @brief register a warning
void registerWarning(int code, std::string_view details = {});
void registerWarning(ErrorCode code, std::string_view details = nullptr);

void toVelocyPack(arangodb::velocypack::Builder& b) const;

Expand Down
2 changes: 1 addition & 1 deletion arangod/GeneralServer/CommTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ void CommTask::sendSimpleResponse(rest::ResponseCode code,

/// @brief send response including error response body
void CommTask::sendErrorResponse(rest::ResponseCode code, rest::ContentType respType,
uint64_t messageId, int errorNum,
uint64_t messageId, ErrorCode errorNum,
std::string_view errorMessage /* = {} */) {
VPackBuffer<uint8_t> buffer;
VPackBuilder builder(buffer);
Expand Down
4 changes: 2 additions & 2 deletions arangod/GeneralServer/CommTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ class CommTask : public std::enable_shared_from_this<CommTask> {

/// @brief send response including error response body
void sendErrorResponse(rest::ResponseCode, rest::ContentType,
uint64_t messageId, int errorNum,
uint64_t messageId, ErrorCode errorNum,
std::string_view errorMessage = {});

/// @brief send simple response including response body
void sendSimpleResponse(rest::ResponseCode, rest::ContentType, uint64_t messageId,
velocypack::Buffer<uint8_t>&&);
Expand Down
2 changes: 1 addition & 1 deletion arangod/GeneralServer/RestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ void RestHandler::compressResponse() {
/// @brief generates an error
////////////////////////////////////////////////////////////////////////////////

void RestHandler::generateError(rest::ResponseCode code, int errorNumber) {
void RestHandler::generateError(rest::ResponseCode code, ErrorCode errorNumber) {
auto const message = TRI_errno_string(errorNumber);

if (message.data() != nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Basics/Exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void Exception::appendLocation() noexcept try {
}

/// @brief construct an error message from a template string
std::string Exception::FillExceptionString(int code, ...) {
std::string Exception::FillExceptionString(ErrorCode code, ...) {
// Note that we rely upon the string being null-terminated.
// The string_view doesn't guarantee that, but we know that all error messages
// are null-terminated.
Expand Down
6 changes: 3 additions & 3 deletions lib/Basics/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ErrorCode TRI_errno() { return LastError._number; }

/// @brief returns the last error as string
std::string_view TRI_last_error() {
int err = LastError._number;
ErrorCode err = LastError._number;

if (err == TRI_ERROR_SYS_ERROR) {
return strerror(LastError._sys);
Expand Down Expand Up @@ -81,8 +81,8 @@ void TRI_set_errno_string(ErrorCode code, char const* msg) {
}

/// @brief return an error message for an error code
std::string_view TRI_errno_string(int code) noexcept {
auto it = ErrorMessages.find(code);
std::string_view TRI_errno_string(ErrorCode code) noexcept {
auto it = ErrorMessages.find(code.asInt());

if (it == ErrorMessages.end()) {
// return a hard-coded string as not all callers check for nullptr
Expand Down
6 changes: 6 additions & 0 deletions lib/Basics/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include <string_view>

#include "Basics/ErrorCode.h"

/// @brief returns the last error
ErrorCode TRI_errno();

Expand All @@ -39,7 +41,11 @@ ErrorCode TRI_set_errno(ErrorCode);
void TRI_set_errno_string(ErrorCode code, char const* msg);

/// @brief return an error message for an error code
<<<<<<< HEAD
std::string_view TRI_errno_string(int code) noexcept;
=======
char const* TRI_errno_string(ErrorCode code) noexcept;
>>>>>>> 2fcec28799eec22959cd24855b891bb929539f39

/// @brief initializes the error messages
void TRI_InitializeError();
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0