Skip to content

Commit 7db6fba

Browse files
authored
Merge pull request #243 from bitshares/update-error-msgs
Update error messages
2 parents 02b7593 + db6ab6c commit 7db6fba

File tree

5 files changed

+40
-21
lines changed

5 files changed

+40
-21
lines changed

.github/workflows/build-and-test-ubuntu-debug.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: Build and run tests in Debug mode
99
strategy:
1010
matrix:
11-
os: [ ubuntu-16.04, ubuntu-18.04, ubuntu-20.04 ]
11+
os: [ ubuntu-18.04, ubuntu-20.04 ]
1212
runs-on: ${{ matrix.os }}
1313
steps:
1414
- name: Install dependencies

.github/workflows/build-and-test-ubuntu-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: Build and run tests in Release mode
99
strategy:
1010
matrix:
11-
os: [ ubuntu-16.04, ubuntu-18.04, ubuntu-20.04 ]
11+
os: [ ubuntu-18.04, ubuntu-20.04 ]
1212
runs-on: ${{ matrix.os }}
1313
steps:
1414
- name: Install dependencies

.github/workflows/sonar-scan.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,19 @@ jobs:
6969
-D Boost_USE_STATIC_LIBS=OFF \
7070
..
7171
popd
72+
# Get OS version to be used in cache key - see https://github.com/actions/cache/issues/543
73+
- run: |
74+
echo "OS_VERSION=`lsb_release -sr`" >> $GITHUB_ENV
7275
- name: Load Cache
7376
uses: actions/cache@v2
7477
with:
7578
path: |
7679
ccache
7780
sonar_cache
78-
key: sonar-${{ github.ref }}-${{ github.sha }}
81+
key: sonar-${{ env.OS_VERSION }}-${{ github.ref }}-${{ github.sha }}
7982
restore-keys: |
80-
sonar-${{ github.ref }}-
81-
sonar-
83+
sonar-${{ env.OS_VERSION }}-${{ github.ref }}-
84+
sonar-${{ env.OS_VERSION }}-
8285
- name: Build
8386
run: |
8487
export CCACHE_DIR="$GITHUB_WORKSPACE/ccache"

include/fc/log/logger.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -164,29 +164,29 @@ namespace fc
164164
// as a quick-fix / workaround, we catch all exceptions here.
165165
// However, to log as much info as possible, it's better to catch exceptions when processing each argument
166166
#define idump( SEQ ) \
167-
{ \
167+
do { \
168168
try { \
169169
ilog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) ); \
170170
} catch( ... ) { \
171171
ilog ( "[ERROR: Got exception while trying to dump ( ${args} )]",("args",FC_DUMP_FORMAT_ARG_NAMES(SEQ)) ); \
172172
} \
173-
}
173+
} while( false )
174174
#define wdump( SEQ ) \
175-
{ \
175+
do { \
176176
try { \
177177
wlog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) ); \
178178
} catch( ... ) { \
179179
wlog ( "[ERROR: Got exception while trying to dump ( ${args} )]",("args",FC_DUMP_FORMAT_ARG_NAMES(SEQ)) ); \
180180
} \
181-
}
181+
} while( false )
182182
#define edump( SEQ ) \
183-
{ \
183+
do { \
184184
try { \
185185
elog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) ); \
186186
} catch( ... ) { \
187187
elog ( "[ERROR: Got exception while trying to dump ( ${args} )]",("args",FC_DUMP_FORMAT_ARG_NAMES(SEQ)) ); \
188188
} \
189-
}
189+
} while( false )
190190

191191
// this disables all normal logging statements -- not something you'd normally want to do,
192192
// but it's useful if you're benchmarking something and suspect logging is causing

include/fc/static_variant.hpp

+26-10
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ class static_variant {
7474

7575
void init_from_tag(tag_type tag)
7676
{
77-
FC_ASSERT( tag >= 0 );
78-
FC_ASSERT( static_cast<size_t>(tag) < count() );
77+
FC_ASSERT( tag >= 0, "Unable to init with a negative tag '${tag}'", ("tag",tag) );
78+
FC_ASSERT( static_cast<size_t>(tag) < count(),
79+
"Unable to init with tag '${tag}' when the number of supported tags is ${count}",
80+
("tag",tag) ("count",count()) );
7981
_tag = tag;
8082
typelist::runtime::dispatch(list(), tag, [this](auto t) {
8183
using T = typename decltype(t)::type;
@@ -235,15 +237,19 @@ class static_variant {
235237
if(_tag == typelist::index_of<list, X>()) {
236238
return *reinterpret_cast<X*>(storage.data());
237239
} else {
238-
FC_THROW_EXCEPTION( fc::assert_exception, "static_variant does not contain a value of type ${t}", ("t",fc::get_typename<X>::name()) );
240+
FC_THROW_EXCEPTION( fc::assert_exception,
241+
"static_variant does not contain a value of type ${t}",
242+
("t",fc::get_typename<X>::name()) );
239243
}
240244
}
241245
template<typename X, typename = type_in_typelist<X>>
242246
const X& get() const {
243247
if(_tag == typelist::index_of<list, X>()) {
244248
return *reinterpret_cast<const X*>(storage.data());
245249
} else {
246-
FC_THROW_EXCEPTION( fc::assert_exception, "static_variant does not contain a value of type ${t}", ("t",fc::get_typename<X>::name()) );
250+
FC_THROW_EXCEPTION( fc::assert_exception,
251+
"static_variant does not contain a value of type ${t}",
252+
("t",fc::get_typename<X>::name()) );
247253
}
248254
}
249255
template<typename visitor>
@@ -269,7 +275,9 @@ class static_variant {
269275
template<typename visitor>
270276
static typename visitor::result_type visit( tag_type tag, visitor& v, void* data )
271277
{
272-
FC_ASSERT( tag >= 0 && static_cast<size_t>(tag) < count(), "Unsupported type ${tag}!", ("tag",tag) );
278+
FC_ASSERT( tag >= 0 && static_cast<size_t>(tag) < count(),
279+
"Unsupported type '${tag}', the number of supported types is ${count}! ",
280+
("tag",tag) ("count",count()) );
273281
return typelist::runtime::dispatch(list(), tag, [&v, data](auto t) {
274282
return v(*reinterpret_cast<typename decltype(t)::type*>(data));
275283
});
@@ -278,7 +286,9 @@ class static_variant {
278286
template<typename visitor>
279287
static typename visitor::result_type visit( tag_type tag, const visitor& v, void* data )
280288
{
281-
FC_ASSERT( tag >= 0 && static_cast<size_t>(tag) < count(), "Unsupported type ${tag}!", ("tag",tag) );
289+
FC_ASSERT( tag >= 0 && static_cast<size_t>(tag) < count(),
290+
"Unsupported type '${tag}', the number of supported types is ${count}! ",
291+
("tag",tag) ("count",count()) );
282292
return typelist::runtime::dispatch(list(), tag, [&v, data](auto t) {
283293
return v(*reinterpret_cast<typename decltype(t)::type*>(data));
284294
});
@@ -287,7 +297,9 @@ class static_variant {
287297
template<typename visitor>
288298
static typename visitor::result_type visit( tag_type tag, visitor& v, const void* data )
289299
{
290-
FC_ASSERT( tag >= 0 && static_cast<size_t>(tag) < count(), "Unsupported type ${tag}!", ("tag",tag) );
300+
FC_ASSERT( tag >= 0 && static_cast<size_t>(tag) < count(),
301+
"Unsupported type '${tag}', the number of supported types is ${count}! ",
302+
("tag",tag) ("count",count()) );
291303
return typelist::runtime::dispatch(list(), tag, [&v, data](auto t) {
292304
return v(*reinterpret_cast<const typename decltype(t)::type*>(data));
293305
});
@@ -296,16 +308,20 @@ class static_variant {
296308
template<typename visitor>
297309
static typename visitor::result_type visit( tag_type tag, const visitor& v, const void* data )
298310
{
299-
FC_ASSERT( tag >= 0 && static_cast<size_t>(tag) < count(), "Unsupported type ${tag}!", ("tag",tag) );
311+
FC_ASSERT( tag >= 0 && static_cast<size_t>(tag) < count(),
312+
"Unsupported type '${tag}', the number of supported types is ${count}! ",
313+
("tag",tag) ("count",count()) );
300314
return typelist::runtime::dispatch(list(), tag, [&v, data](auto t) {
301315
return v(*reinterpret_cast<const typename decltype(t)::type*>(data));
302316
});
303317
}
304318

305319
static constexpr size_t count() { return typelist::length<list>(); }
306320
void set_which( tag_type tag ) {
307-
FC_ASSERT( tag >= 0 );
308-
FC_ASSERT( static_cast<size_t>(tag) < count() );
321+
FC_ASSERT( tag >= 0, "Unable to set a negative tag '${tag}'", ("tag",tag) );
322+
FC_ASSERT( static_cast<size_t>(tag) < count(),
323+
"Unable to set tag '${tag}' when the number of supported tags is ${count}",
324+
("tag",tag) ("count",count()) );
309325
clean();
310326
init_from_tag(tag);
311327
}

0 commit comments

Comments
 (0)