Skip to content

Commit 02f1044

Browse files
committed
CR: A clean look at the code, minor tweaks.
1 parent 71c6d58 commit 02f1044

File tree

10 files changed

+18
-36
lines changed

10 files changed

+18
-36
lines changed

Blocks/HTTP/docu/server/docu_03httpserver_04_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const auto port = FLAGS_docu_net_server_port_04;
8383
}
8484
} catch (const current::Exception& e) {
8585
// TODO(dkorolev): Catch the right exception type.
86-
r(PennyOutput{e.DetailedDescription(), 0});
86+
r(PennyOutput{e.what(), 0});
8787
}
8888
});
8989
EXPECT_EQ("{\"error\":\"\",\"result\":5}\n", HTTP(POST(Printf("http://localhost:%d/penny", port), PennyInput{"add",{2,3}})).body);

Blocks/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const auto scope = HTTP(port).Register("/penny", [](Request r) {
9191
}
9292
} catch (const current::Exception& e) {
9393
// TODO(dkorolev): Catch the right exception type.
94-
r(PennyOutput{e.DetailedDescription(), 0});
94+
r(PennyOutput{e.what(), 0});
9595
}
9696
});
9797
```

Bricks/exception.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ class Exception : public std::exception {
7676
};
7777

7878
// Extra parenthesis around `e((E))` are essential to not make it a function declaration.
79-
#define CURRENT_THROW(E) \
80-
{ \
81-
auto e((E)); \
82-
e.FillDetails(#E, __FILE__, __LINE__); \
83-
throw e; \
79+
// Also, call it `_e_` to avoid name collisions.
80+
#define CURRENT_THROW(E) \
81+
{ \
82+
auto _e_((E)); \
83+
_e_.FillDetails(#E, __FILE__, __LINE__); \
84+
throw _e_; \
8485
}
8586

8687
} // namespace current

Bricks/sync/test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ TEST(WaitableAtomic, Smoke) {
255255
EXPECT_TRUE(copy_of_object.x_done);
256256
EXPECT_TRUE(copy_of_object.y_done);
257257

258-
// Both threads should have had enough time to increment their counters at least by a bit.
259-
// Technically, the EXPECT-s below make the test flaky, but the range is generous enough.
258+
// Both threads should have had enough time to increment their counters at least by a bit.
259+
// Technically, the EXPECT-s below make the test flaky, but the range is generous enough.
260260
#ifndef CURRENT_COVERAGE_REPORT_MODE
261261
EXPECT_GT(copy_of_object.x, 10u);
262262
EXPECT_LT(copy_of_object.x, 100u);

Integrations/OneSignal/ios_notifications_sender.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ server {
109109
// Send one iOS push notification.
110110
// Returns true on success.
111111
// Returns false on "regular" errors.
112-
// Throws on terrible errors, with the returned `e.DetailedDescription()` good for journaling and further
113-
// investigation.
112+
// Throws on terrible errors, with the returned `e.DetailedDescription()` good for journaling.
114113
bool Push(const std::string& recipient_player_id,
115114
const std::string& message = "",
116115
int32_t increase_counter = 0) const {
@@ -147,23 +146,23 @@ server {
147146
ParseJSON(response.body, parsed_response);
148147
} catch (const Exception& e) {
149148
// Resulting JSON error: Fatal.
150-
throw OneSignalPushNotificationException("OneSignal iOS push error A: " + e.DetailedDescription());
149+
CURRENT_THROW(OneSignalPushNotificationException("OneSignal iOS push error A: " + e.DetailedDescription()));
151150
}
152151
if (!Exists(parsed_response.recipients)) {
153152
if (Exists(parsed_response.errors)) {
154153
// Some "regular" error occurred: Non-fatal.
155154
return false;
156155
} else {
157156
// Some unexpected error occurred: Fatal.
158-
throw OneSignalPushNotificationException("OneSignal iOS push error Q: " + response.body);
157+
CURRENT_THROW(OneSignalPushNotificationException("OneSignal iOS push error Q: " + response.body));
159158
}
160159
}
161160
if (Value(parsed_response.recipients) == 0) {
162161
// Just could not send the notification: Non-fatal.
163162
return false;
164163
} else if (Value(parsed_response.recipients) > 1) {
165164
// Potentially sent the notification to more than one user: Fatal.
166-
throw OneSignalPushNotificationException("OneSignal iOS push error Z: " + response.body);
165+
CURRENT_THROW(OneSignalPushNotificationException("OneSignal iOS push error Z: " + response.body));
167166
} else {
168167
// The notification has been sent to exactly one user: OK.
169168
return true;

Storage/api.h

+1
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ class RESTfulStorage {
400400
using mutable_fields_t = MutableFields<STORAGE_IMPL>;
401401

402402
// TODO(dkorolev): `unique_ptr` and move semantics. Move to `-std=c++14` maybe? :-)
403+
// FIXME_DIMA <-- keep this marker for me to find it once we do move to C++14.
403404
using cqs_universal_parser_t = std::function<std::shared_ptr<CurrentStruct>(Request&)>;
404405
using cqs_query_handler_t = std::function<Response(
405406
immutable_fields_t, std::shared_ptr<CurrentStruct> command, const std::string& restful_url_prefix)>;

Storage/rest/types.h

+1
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ CURRENT_STRUCT(CQSUserCodeError, generic::RESTGenericResponse) {
326326
map_t map;
327327
map["error"] = e.OriginalDescription();
328328
#ifndef NDEBUG
329+
// As discussed between @dkorolev and @mzhurovich, only return `caller`, `file`, and `line` in non-`NDEBUG` builds.
329330
map["caller"] = e.Caller();
330331
if (e.File()) {
331332
map["file"] = e.File();

TypeSystem/Reflection/test.cc

-12
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,6 @@ struct CollectFieldValues {
327327
}
328328
};
329329

330-
CURRENT_STRUCT(StructWithSizeTWhichShouldBeUInt64T) {
331-
CURRENT_FIELD(a, uint64_t);
332-
CURRENT_FIELD(b, size_t);
333-
};
334-
335-
static_assert(std::is_same<decltype(std::declval<StructWithSizeTWhichShouldBeUInt64T>().a), uint64_t>::value, "");
336-
static_assert(std::is_same<decltype(std::declval<StructWithSizeTWhichShouldBeUInt64T>().b), uint64_t>::value, "");
337-
338-
static_assert(std::is_same<decltype(std::declval<StructWithSizeTWhichShouldBeUInt64T>().a),
339-
decltype(std::declval<StructWithSizeTWhichShouldBeUInt64T>().b)>::value,
340-
"");
341-
342330
} // namespace reflection_test
343331

344332
TEST(Reflection, VisitAllFieldsWithoutObject) {

TypeSystem/struct.h

-7
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,6 @@ struct FieldImpl<DF, T> {
9696
typedef T type;
9797
};
9898

99-
// Allow `size_t` in JSON-serializable types, but make it `uint64_t` right way.
100-
// Apparently, this is important when compiling on OS X, where `size_t` and `uint64_t` are different types. -- D.K.
101-
template <>
102-
struct FieldImpl<DF, size_t> {
103-
typedef uint64_t type;
104-
};
105-
10699
template <typename T>
107100
struct FieldImpl<FC, T> {
108101
// TODO: Read on padding.

scripts/full-test.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,11 @@ done
6464
echo -e -n "\033[0m"
6565

6666
(
67-
# Compile and run The Big Test.
67+
# Build and run The Big Test.
68+
6869
ln -sf "$CURRENT_SCRIPTS_DIR/MakefileWithCurrentBuild" "$FULL_TEST_DIR_NAME/Makefile"
6970
(cd "$FULL_TEST_DIR_NAME" ; make phony_current_build > /dev/null ; unlink Makefile)
70-
)
7171

72-
(
7372
cd "$FULL_TEST_DIR_NAME"
7473

7574
echo -e "\033[0m"

0 commit comments

Comments
 (0)