in functions_framework_builder/lib/src/generic_function_type.dart [143:195]
factory _GenericFactoryData(
bool withContext,
bool isVoid,
JsonParamInfo info,
String target,
String function,
) {
final jsonTypeDisplay = info.jsonType.toStringNonNullable();
final typeDisplayName = info.paramType == null
? jsonTypeDisplay
: '$functionsLibraryPrefix.'
'${info.paramType!.toStringNonNullable()}';
final returnBlock = info.paramType == null
? 'return $_jsonParamName;'
: '''
try {
return $typeDisplayName.$fromJsonFactoryName($_jsonParamName);
} catch (e, stack) {
throw BadRequestException(
400,
'There was an error parsing the provided JSON data.',
innerError: e,
innerStack: stack,
);
}
''';
final body = '''
if ($_jsonParamName is $jsonTypeDisplay) {
$returnBlock
}
throw BadRequestException(
400,
'The provided JSON is not the expected type '
'`$jsonTypeDisplay`.',
);
''';
return _GenericFactoryData._(
isVoid
? withContext
? _voidWithContextConstructorName
: _voidConstructorName
: withContext
? _withContextConstructorName
: _constructorName,
target,
function,
typeDisplayName,
body,
);
}