Skip to content

Commit a55de60

Browse files
committed
Cleanup some error handling
1 parent 62cada5 commit a55de60

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

src/GraphQLResponse.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,9 @@ IdType Value::release<IdType>()
675675
{
676676
auto stringValue = std::move(stringData.string);
677677

678-
return internal::Base64::fromBase64(stringValue);
678+
return internal::Base64::validateBase64(stringValue)
679+
? IdType { internal::Base64::fromBase64(stringValue) }
680+
: IdType { std::move(stringValue) };
679681
}
680682
}
681683
else if (std::holds_alternative<IdType>(_data))

src/GraphQLService.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -674,14 +674,7 @@ response::IdType ModifiedArgument<response::IdType>::convert(const response::Val
674674
throw schema_exception { { "not an ID" } };
675675
}
676676

677-
try
678-
{
679-
return response::Value { value }.release<response::IdType>();
680-
}
681-
catch (const std::logic_error& ex)
682-
{
683-
throw schema_exception { { ex.what() } };
684-
}
677+
return response::Value { value }.release<response::IdType>();
685678
}
686679

687680
void blockSubFields(const ResolverParams& params)
@@ -852,15 +845,6 @@ void ModifiedResult<response::IdType>::validateScalar(const response::Value& val
852845
{
853846
throw schema_exception { { R"ex(not a valid ID value)ex" } };
854847
}
855-
856-
try
857-
{
858-
value.get<response::IdType>();
859-
}
860-
catch (const std::logic_error& ex)
861-
{
862-
throw schema_exception { { ex.what() } };
863-
}
864848
}
865849

866850
template <>

0 commit comments

Comments
 (0)