[dart][dart-dio-next] Add stacktraces to manual DioError instances (#9549)

This commit is contained in:
Peter Leibiger
2021-05-24 04:54:51 +02:00
committed by GitHub
parent 48924eb1a0
commit be84c44fcc
8 changed files with 94 additions and 94 deletions

View File

@@ -76,7 +76,7 @@ class {{classname}} {
try {
{{#useBuiltValue}}{{>serialization/built_value/serialize}}{{/useBuiltValue}}
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -85,7 +85,7 @@ class {{classname}} {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
{{/hasBodyOrFormParams}}
@@ -104,13 +104,13 @@ class {{classname}} {
try {
{{#useBuiltValue}}{{>serialization/built_value/deserialize}}{{/useBuiltValue}}
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<{{{returnType}}}>(

View File

@@ -52,7 +52,7 @@ class AnotherFakeApi {
const _type = FullType(ModelClient);
_bodyData = _serializers.serialize(modelClient, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -61,7 +61,7 @@ class AnotherFakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -83,13 +83,13 @@ class AnotherFakeApi {
specifiedType: _responseType,
) as ModelClient;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<ModelClient>(

View File

@@ -62,13 +62,13 @@ class DefaultApi {
specifiedType: _responseType,
) as InlineResponseDefault;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<InlineResponseDefault>(

View File

@@ -72,13 +72,13 @@ class FakeApi {
specifiedType: _responseType,
) as HealthCheckResult;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<HealthCheckResult>(
@@ -137,7 +137,7 @@ class FakeApi {
const _type = FullType(Pet);
_bodyData = _serializers.serialize(pet, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -146,7 +146,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -196,7 +196,7 @@ class FakeApi {
try {
_bodyData = body;
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -205,7 +205,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -223,13 +223,13 @@ class FakeApi {
try {
_responseData = _response.data as bool;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<bool>(
@@ -279,7 +279,7 @@ class FakeApi {
const _type = FullType(OuterComposite);
_bodyData = outerComposite == null ? null : _serializers.serialize(outerComposite, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -288,7 +288,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -310,13 +310,13 @@ class FakeApi {
specifiedType: _responseType,
) as OuterComposite;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<OuterComposite>(
@@ -365,7 +365,7 @@ class FakeApi {
try {
_bodyData = body;
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -374,7 +374,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -392,13 +392,13 @@ class FakeApi {
try {
_responseData = _response.data as num;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<num>(
@@ -447,7 +447,7 @@ class FakeApi {
try {
_bodyData = body;
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -456,7 +456,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -474,13 +474,13 @@ class FakeApi {
try {
_responseData = _response.data as String;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<String>(
@@ -530,7 +530,7 @@ class FakeApi {
const _type = FullType(OuterObjectWithEnumProperty);
_bodyData = _serializers.serialize(outerObjectWithEnumProperty, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -539,7 +539,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -561,13 +561,13 @@ class FakeApi {
specifiedType: _responseType,
) as OuterObjectWithEnumProperty;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<OuterObjectWithEnumProperty>(
@@ -617,7 +617,7 @@ class FakeApi {
const _type = FullType(FileSchemaTestClass);
_bodyData = _serializers.serialize(fileSchemaTestClass, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -626,7 +626,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -679,7 +679,7 @@ class FakeApi {
const _type = FullType(User);
_bodyData = _serializers.serialize(user, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -688,7 +688,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -739,7 +739,7 @@ class FakeApi {
const _type = FullType(ModelClient);
_bodyData = _serializers.serialize(modelClient, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -748,7 +748,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -770,13 +770,13 @@ class FakeApi {
specifiedType: _responseType,
) as ModelClient;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<ModelClient>(
@@ -858,7 +858,7 @@ class FakeApi {
if (callback != null) r'callback': encodeFormParameter(_serializers, callback, const FullType(String)),
};
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -867,7 +867,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -933,7 +933,7 @@ class FakeApi {
if (enumFormString != null) r'enum_form_string': encodeFormParameter(_serializers, enumFormString, const FullType(String)),
};
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -942,7 +942,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -1049,7 +1049,7 @@ class FakeApi {
const _type = FullType(BuiltMap, [FullType(String), FullType(String)]);
_bodyData = _serializers.serialize(requestBody, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -1058,7 +1058,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -1112,7 +1112,7 @@ class FakeApi {
r'param2': encodeFormParameter(_serializers, param2, const FullType(String)),
};
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -1121,7 +1121,7 @@ class FakeApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(

View File

@@ -59,7 +59,7 @@ class FakeClassnameTags123Api {
const _type = FullType(ModelClient);
_bodyData = _serializers.serialize(modelClient, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -68,7 +68,7 @@ class FakeClassnameTags123Api {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -90,13 +90,13 @@ class FakeClassnameTags123Api {
specifiedType: _responseType,
) as ModelClient;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<ModelClient>(

View File

@@ -61,7 +61,7 @@ class PetApi {
const _type = FullType(Pet);
_bodyData = _serializers.serialize(pet, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -70,7 +70,7 @@ class PetApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -185,13 +185,13 @@ class PetApi {
specifiedType: _responseType,
) as BuiltList<Pet>;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<BuiltList<Pet>>(
@@ -258,13 +258,13 @@ class PetApi {
specifiedType: _responseType,
) as BuiltSet<Pet>;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<BuiltSet<Pet>>(
@@ -332,13 +332,13 @@ class PetApi {
specifiedType: _responseType,
) as Pet;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<Pet>(
@@ -393,7 +393,7 @@ class PetApi {
const _type = FullType(Pet);
_bodyData = _serializers.serialize(pet, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -402,7 +402,7 @@ class PetApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -462,7 +462,7 @@ class PetApi {
if (status != null) r'status': encodeFormParameter(_serializers, status, const FullType(String)),
};
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -471,7 +471,7 @@ class PetApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -531,7 +531,7 @@ class PetApi {
if (file != null) r'file': MultipartFile.fromBytes(file, filename: r'file'),
});
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -540,7 +540,7 @@ class PetApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -562,13 +562,13 @@ class PetApi {
specifiedType: _responseType,
) as ApiResponse;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<ApiResponse>(
@@ -627,7 +627,7 @@ class PetApi {
r'requiredFile': MultipartFile.fromBytes(requiredFile, filename: r'requiredFile'),
});
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -636,7 +636,7 @@ class PetApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -658,13 +658,13 @@ class PetApi {
specifiedType: _responseType,
) as ApiResponse;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<ApiResponse>(

View File

@@ -110,13 +110,13 @@ class StoreApi {
specifiedType: _responseType,
) as BuiltMap<String, int>;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<BuiltMap<String, int>>(
@@ -177,13 +177,13 @@ class StoreApi {
specifiedType: _responseType,
) as Order;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<Order>(
@@ -233,7 +233,7 @@ class StoreApi {
const _type = FullType(Order);
_bodyData = _serializers.serialize(order, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -242,7 +242,7 @@ class StoreApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -264,13 +264,13 @@ class StoreApi {
specifiedType: _responseType,
) as Order;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<Order>(

View File

@@ -53,7 +53,7 @@ class UserApi {
const _type = FullType(User);
_bodyData = _serializers.serialize(user, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -62,7 +62,7 @@ class UserApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -113,7 +113,7 @@ class UserApi {
const _type = FullType(BuiltList, [FullType(User)]);
_bodyData = _serializers.serialize(user, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -122,7 +122,7 @@ class UserApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -173,7 +173,7 @@ class UserApi {
const _type = FullType(BuiltList, [FullType(User)]);
_bodyData = _serializers.serialize(user, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -182,7 +182,7 @@ class UserApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
@@ -284,13 +284,13 @@ class UserApi {
specifiedType: _responseType,
) as User;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<User>(
@@ -350,13 +350,13 @@ class UserApi {
try {
_responseData = _response.data as String;
} catch (error) {
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
return Response<String>(
@@ -446,7 +446,7 @@ class UserApi {
const _type = FullType(User);
_bodyData = _serializers.serialize(user, specifiedType: _type);
} catch(error) {
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
@@ -455,7 +455,7 @@ class UserApi {
),
type: DioErrorType.other,
error: error,
);
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(