Skip to content

Commit fc84a80

Browse files
committed
Replace assert with throw if applicable
1 parent 2c03035 commit fc84a80

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

include/tao/json/internal/write.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace tao
6060
}
6161
break;
6262
default:
63-
assert( false );
63+
throw std::logic_error( "invalid value for tao::json::type" ); // LCOV_EXCL_LINE
6464
}
6565
}
6666

include/tao/json/pointer.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace tao
5252
result += '/';
5353
break;
5454
default:
55-
assert( !"code should be unreachable" ); // LCOV_EXCL_LINE
55+
throw std::logic_error( "code should be unreachable" ); // LCOV_EXCL_LINE
5656
}
5757
++p;
5858
break;

include/tao/json/self_contained.hh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace tao
1313
// recursively checks for the existence if POINTER nodes,
1414
// returns true is no POINTER nodes were found.
1515
template< template< typename ... > class Traits >
16-
bool is_self_contained( basic_value< Traits > & v )
16+
bool is_self_contained( basic_value< Traits > & v ) noexcept
1717
{
1818
switch ( v.type() ) {
1919
case json::type::NULL_:
@@ -25,14 +25,14 @@ namespace tao
2525
return true;
2626
case json::type::ARRAY:
2727
for ( auto & e : v.unsafe_get_array() ) {
28-
if( !is_self_contained( e ) ) {
28+
if ( ! is_self_contained( e ) ) {
2929
return false;
3030
}
3131
}
3232
return true;
3333
case json::type::OBJECT:
3434
for ( auto & e : v.unsafe_get_object() ) {
35-
if( !is_self_contained( e.second ) ) {
35+
if ( ! is_self_contained( e.second ) ) {
3636
return false;
3737
}
3838
}
@@ -67,7 +67,7 @@ namespace tao
6767
}
6868
return;
6969
case json::type::POINTER:
70-
if( const auto * p = v.unsafe_get_pointer() ) {
70+
if ( const auto * p = v.unsafe_get_pointer() ) {
7171
v = * p;
7272
make_self_contained( v );
7373
}
@@ -76,7 +76,7 @@ namespace tao
7676
}
7777
return;
7878
}
79-
assert( false ); // LCOV_EXCL_LINE
79+
throw std::logic_error( "invalid value for tao::json::type" ); // LCOV_EXCL_LINE
8080
}
8181

8282
} // json

0 commit comments

Comments
 (0)