Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Http client exception not handled properly resulting in incorrectly formatted error #1021

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 1 addition & 53 deletions packages/dart/lib/parse_server_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'dart:typed_data';
import 'package:collection/collection.dart';
import 'package:cross_file/cross_file.dart';
import 'package:dio/dio.dart';
import 'package:http/http.dart';
import 'package:meta/meta.dart';
import 'package:mime/mime.dart';
import 'package:path/path.dart' as path;
Expand All @@ -29,111 +30,58 @@ export 'src/network/parse_dio_client.dart';
export 'src/network/parse_http_client.dart';

part 'src/base/parse_constants.dart';

part 'src/data/parse_core_data.dart';

part 'src/data/parse_subclass_handler.dart';

part 'src/enums/parse_enum_api_rq.dart';

part 'src/network/options.dart';

part 'src/network/parse_client.dart';

part 'src/network/parse_connectivity.dart';

part 'src/network/parse_live_query.dart';

part 'src/network/parse_query.dart';

part 'src/objects/parse_acl.dart';

part 'src/objects/parse_array.dart';

part 'src/objects/parse_base.dart';

part 'src/objects/parse_cloneable.dart';

part 'src/objects/parse_config.dart';

part 'src/objects/parse_error.dart';

part 'src/objects/parse_exception.dart';

part 'src/objects/parse_file.dart';

part 'src/objects/parse_file_base.dart';

part 'src/objects/parse_file_web.dart';

part 'src/objects/parse_function.dart';

part 'src/objects/parse_geo_point.dart';

part 'src/objects/parse_installation.dart';

part 'src/objects/parse_number.dart';

part 'src/objects/parse_object.dart';

part 'src/objects/parse_operation/parse_add_operation.dart';

part 'src/objects/parse_operation/parse_add_relation_operation.dart';

part 'src/objects/parse_operation/parse_add_unique_operation.dart';

part 'src/objects/parse_operation/parse_increment_operation.dart';

part 'src/objects/parse_operation/parse_operation.dart';

part 'src/objects/parse_operation/parse_remove_operation.dart';

part 'src/objects/parse_operation/parse_remove_relation_operation.dart';

part 'src/objects/parse_relation.dart';

part 'src/objects/parse_response.dart';

part 'src/objects/parse_save_state_aware_child.dart';

part 'src/objects/parse_session.dart';

part 'src/objects/parse_user.dart';

part 'src/objects/parse_x_file.dart';

part 'src/objects/response/parse_error_response.dart';

part 'src/objects/response/parse_exception_response.dart';

part 'src/objects/response/parse_response_builder.dart';

part 'src/objects/response/parse_response_utils.dart';

part 'src/objects/response/parse_success_no_results.dart';

part 'src/storage/core_store.dart';

part 'src/storage/core_store_memory.dart';

part 'src/storage/core_store_sem_impl.dart';

part 'src/storage/xxtea_codec.dart';

part 'src/utils/parse_date_format.dart';

part 'src/utils/parse_decoder.dart';

part 'src/utils/parse_encoder.dart';

part 'src/utils/parse_live_list.dart';

part 'src/utils/parse_logger.dart';

part 'src/utils/parse_login_helpers.dart';

part 'src/utils/parse_utils.dart';

part 'src/utils/valuable.dart';

class Parse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
));
}

if (exception is ClientException) {
Copy link
Member

@mbfakourii mbfakourii Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use two clients, dio and http, at Parse Flutter !

In this change you are using the functions of the http package. Will this not cause any problems when we use the dio package client?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DioException is already being handled above but ClientException was missing.

return ParseResponse(
error: ParseError(message: exception.message, exception: exception),

Check warning on line 27 in packages/dart/lib/src/objects/response/parse_exception_response.dart

View check run for this annotation

Codecov / codecov/patch

packages/dart/lib/src/objects/response/parse_exception_response.dart#L26-L27

Added lines #L26 - L27 were not covered by tests
);
}

return ParseResponse(
error: ParseError(message: exception.toString(), exception: exception));
}