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

Override Message default equalty operator #235

Closed
wants to merge 7 commits into from

Conversation

busslina
Copy link

@busslina busslina commented Feb 3, 2023

(Change 1): Compares type, chatId and messageId.

Compares type, chatId and messageId
Example of error stack trace:

http response json data: {ok: false, error_code: 400, description: Bad Request: message can't be deleted}

Unhandled exception:
type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast
#0      _$ErrorResponseFromJson (package:teledart/src/telegram/model.g.dart:3578:30)
DinoLeung#1      new ErrorResponse.fromJson (package:teledart/src/telegram/models/response.dart:78:7)
DinoLeung#2      HttpClient._parseResponse (package:teledart/src/util/http_client.dart:43:51)
DinoLeung#3      _rootRunUnary (dart:async/zone.dart:1399:47)
<asynchronous suspension>
DinoLeung#4      Telegram.deleteMessage (package:teledart/src/telegram/telegram.dart:2346:12)
<asynchronous suspension>
DinoLeung#5      TelegramMessageRegister.removeMessages.<anonymous closure> (package:busslina_dart_rest_lib/core/module>
<asynchronous suspension>
DinoLeung#6      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
<asynchronous suspension>
DinoLeung#7      _TelegramHandler._getMenuCommandHandler (package:busslina_dart_rest_lib/core/modules/system.module.dar>
<asynchronous suspension>
DinoLeung#8      TelegramBot.onCommand.<anonymous closure> (package:busslina_dart_telegram_lib/src/core/app/telegram_bo>
<asynchronous suspension>
DinoLeung#9      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
<asynchronous suspension>
autodia-server.service: Main process exited, code=exited, status=255/EXCEPTION
@busslina
Copy link
Author

busslina commented Feb 6, 2023

(Change 2): Resolved null ErrorResponse parameters field

Example of error stack trace:

HTTP response json data: {ok: false, error_code: 400, description: Bad Request: message can't be deleted}

Unhandled exception:
type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast
#0 _$ErrorResponseFromJson (package:teledart/src/telegram/model.g.dart:3578:30)
#1 new ErrorResponse.fromJson (package:teledart/src/telegram/models/response.dart:78:7)
#2 HttpClient._parseResponse (package:teledart/src/util/http_client.dart:43:51)
#3 _rootRunUnary (dart:async/zone.dart:1399:47)

#4 Telegram.deleteMessage (package:teledart/src/telegram/telegram.dart:2346:12)

#5 TelegramMessageRegister.removeMessages. (package:busslina_dart_rest_lib/core/module>

#6 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)

#7 _TelegramHandler._getMenuCommandHandler (package:busslina_dart_rest_lib/core/modules/system.module.dar>

#8 TelegramBot.onCommand. (package:busslina_dart_telegram_lib/src/core/app/telegram_bo>

#9 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)

autodia-server.service: Main process exited, code=exited, status=255/EXCEPTION

Copy link
Owner

@DinoLeung DinoLeung left a comment

Choose a reason for hiding this comment

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

@busslina thanks for submitting this PR, it seems that it is addressing multiple thing here. Will be closing this PR, and create a new one to address the issue which is the ResponseParameters type error.

if (error.isTooManyRequests()) {
retryDelay = error.parameters?.retryAfter_ ?? retryDelay;
_onRecursivePollingError(error);
} else if (error.code == 409) {
Copy link
Owner

Choose a reason for hiding this comment

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

409 error is a conflict error, and it does not seem to be a retry-able error.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, but like in 429 error, it must be a way to catch it and not let the whole app crash

Copy link
Owner

Choose a reason for hiding this comment

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

this PR has export the http client along with the exception class 👍

@@ -52,4 +52,18 @@ class Audio {

factory Audio.fromJson(Map<String, dynamic> json) => _$AudioFromJson(json);
Map<String, dynamic> toJson() => _$AudioToJson(this);

@override
String toString() => '''Audio
Copy link
Owner

Choose a reason for hiding this comment

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

what are these toString methods for?

Copy link
Author

Choose a reason for hiding this comment

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

These are methods to debug that I use internally on my fork

@@ -212,4 +212,13 @@ class Message {
return null;
}
}

@override
Copy link
Owner

Choose a reason for hiding this comment

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

this is cool

@@ -65,7 +65,7 @@ class ErrorResponse {
bool ok;
String description;
int errorCode;
ResponseParameters parameters;
ResponseParameters? parameters;
Copy link
Owner

Choose a reason for hiding this comment

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

good catch

@DinoLeung DinoLeung closed this Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants