moon

unread,
Aug 9, 2018, 6:45:53 AM8/9/18
to MIT App Inventor Forum
Hi there,

I'm trying to catch the famous 2202 error from Yandex in order to alert the user with a coloured button.
As by now, when this occurs  my 

IF (ResponseCode==2202) 
THEN 
       SetBckColor(X) to RED
ELSE
       SetBckColor(X) to GREEN
       Proceed & do your job
ENDIF


test doesn't work.
Any reason for that ?

Any idea how to handle that?

Many thanks in advance
M

Chris Ward

unread,
Aug 9, 2018, 8:10:15 AM8/9/18
to MIT App Inventor Forum
Hi moon

You are not telling us exactly what in the test is not working.........

There is another code to catch: 2201

Do you have the error occur frequently? If you do, it is not likely to be the Yandex server, but a gremlin in your code.

Post your blocks!

Save Blocks Image For Forum.png





Chris Ward

unread,
Aug 9, 2018, 8:11:51 AM8/9/18
to MIT App Inventor Forum
Make sure your language codes are correct (2 characters only)

moon

unread,
Aug 9, 2018, 8:26:47 AM8/9/18
to MIT App Inventor Forum
Hi Chris,
No it's not happening too frequently. Depends always on the bandwidth.

moon

unread,
Aug 9, 2018, 8:36:05 AM8/9/18
to MIT App Inventor Forum
Hi Chris,

Attached a screenshot of my function


Screen Shot 2018-08-09 at 14.31.10.png

moon

unread,
Aug 9, 2018, 8:52:11 AM8/9/18
to MIT App Inventor Forum
Silly me forget to answer your specific question about the error.
I try to catch the 2202 error displayed as a warning by yandex and use it to alert the user.
It looks like the error is not 2202 while in the alert it says error 2202.
OR
the fact that I got the error alter in some way my programming logic.

when no error then ELSE part works fine
when not, nothing happens.

hope it helps.
and thx again for the effort.

M

Chris Ward

unread,
Aug 9, 2018, 9:00:37 AM8/9/18
to MIT App Inventor Forum
.... interesting note from Yandex:

If you got an error message when processing a request:

  • Check whether all special characters are escaped in the text parameter.
  • Check whether the request string has any extra spaces.
  •  Make sure you are using the correct key.
  • The key for the Yandex.Translate API begins with the characters trnsl.
  • If you got a 404 error, increase your request limit.

SteveJG

unread,
Aug 9, 2018, 9:03:44 AM8/9/18
to MIT App Inventor Forum
A work around might  be to check the    length of your   orange  get translation block.  If the length is 0 

Chris Ward

unread,
Aug 9, 2018, 9:37:15 AM8/9/18
to MIT App Inventor Forum
Hi Moon

There is actually a huge list of potential errors. From a developer point of view, it might be interesting to save them (append a text file) - then if a User complains about the app having a lot of errors, you could have the app email you that file content to see exactly what might be wrong.

For your Block Code, test for a positive instead of a negative - so test for code 200 (= all is well) and continue running the code. You can still use your method of signalling a fault, it's just easier to test for one code than for 100.

moon

unread,
Aug 9, 2018, 9:40:30 AM8/9/18
to MIT App Inventor Forum
Interesting indeed.


to try to find an option.
Unless I missed something there is no value for "non error"

am I wrong ?

meanwhile, still having that 2202 not catched even with a control of the answer from Yandex as you suggested.

What bothers me is the fact that it's not an exception handled by the system. The App keeps going after the failure.


moon

unread,
Aug 9, 2018, 9:43:32 AM8/9/18
to MIT App Inventor Forum
Oups

your suggestion appeared here after I sent my answer. will definitely try that non 200 status.
thx

moon

unread,
Aug 9, 2018, 10:54:38 AM8/9/18
to MIT App Inventor Forum
Hi Chris,

A quicky feedback after using your suggestion of a non 200 catch.

It works in some cases not always

from my end it's like if the responsecode is not always sent by Yandex.
In other words I easily get a 200 while nothing in the answer.

I might be wrong but it doesn't carry everytime the exact error (if it's considered as such by Yandex).

However when the translation is ok, apparently I get that 200

Mmmh have still to work on it and whatever suggestion is welcome.

Can set a little example if it helps.

M

moon

unread,
Aug 10, 2018, 1:06:28 AM8/10/18
to MIT App Inventor Forum
Hi Steve,

Thanks for the suggestion.
At the end glad to say that both options worked for me (i.e length & non 200 response)


Many thanks for both Chris & you

I'll mark this thread as completed.
Reply all
Reply to author
Forward
0 new messages