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

Elevate Error of API #80

Open
vidm27 opened this issue Apr 24, 2023 · 5 comments
Open

Elevate Error of API #80

vidm27 opened this issue Apr 24, 2023 · 5 comments

Comments

@vidm27
Copy link

vidm27 commented Apr 24, 2023

Meta in their API has specific code for each type error, you can read this error, code and raise exception that we can catch, to know that is wrong in the send message because the error is silent.

2023-04-24 10:04:53,261 - root - INFO - Image not sent to 50763036683 2023-04-24 10:04:53,261 - root - INFO - Status code: 400 2023-04-24 10:04:53,262 - root - ERROR - {'error': {'message': '(#131030) Recipient phone number not in allowed list', 'type': 'OAuthException', 'code': 131030, 'error_data': {'messaging_product': 'whatsapp', 'details': 'El número de teléfono del destinatario no está en la lista de autorizados: Agrega el número de teléfono del destinatario a la lista de destinatarios y vuelve a intentarlo.'}, 'fbtrace_id': 'A4yeLb3JmDl2ZvQMvBgCANu'}}

ObjectIdException

	"error": {
		"message": "Unsupported post request. Object with ID '118130101241809' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api",
		"type": "GraphMethodException",
		"code": 100,
		"error_subcode": 33,
		"fbtrace_id": "A2H9tBUK0RHUB91NwUjrY23"
	}
}

RecipientPhoneNumberException

	"error": {
		"message": "(#131030) Recipient phone number not in allowed list",
		"type": "OAuthException",
		"code": 131030,
		"error_data": {
			"messaging_product": "whatsapp",
			"details": "El número de teléfono del destinatario no está en la lista de autorizados: Agrega el número de teléfono del destinatario a la lista de destinatarios y vuelve a intentarlo."
		},
		"fbtrace_id": "AguKtar08vzPr310wo-jcjY"
	}
} 
@filipporomani
Copy link
Contributor

Nice idea. I'll try to implement this asap!

@filipporomani
Copy link
Contributor

Well, the only actual issue with this is that a full map of the Meta API errors should be created, and there are thousands of them (including sub-codes ofc).

@filipporomani
Copy link
Contributor

Your actual listed errors might not be the right one: I mean, there are many codes that can mean the same (or almost) error.

@soerenetler
Copy link
Collaborator

I think a general ``WhatsAppErrorwould be good for now. It would have fields likemessage`, `type`. `code`, `error_data`, `fbtrace_id`. The challenge currently is, that you can not handle exceptions because they are just silent and not raised in the code.

@filipporomani
Copy link
Contributor

Yeah that's the point. I opened #88 to also be able to create a better handler at the beginning: in fact, as FB says, version 16 of the API removes subcodes and only has major general codes.
I suggest updating the API version first, then we can try to implement an error handler.

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

No branches or pull requests

3 participants