Android Question error: code too large for try statement

Nicolás Cieri

Active Member
Licensed User
Hello, I have a very large sub, but it is necessary.

What can be done to avoid this error and be able to work with the normal debugger?

Thanks.

error: code too large for try statement
catch (Exception e) {
 

JohnC

Expert
Licensed User
Longtime User
My first guess is to try to break up the large sub into smaller subs to prevent this error.

If you want to post the code to your sub, we can provide suggestions on how to break it into different subs.
 
Upvote 0

Nicolás Cieri

Active Member
Licensed User
Is it the only way? It would be somewhat complicated, since all the code is closely related.

Is it limited to a maximum of characters per 'sub' ?, or what happens?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I have never heard of this error. But apparently there is some type of limit built into the compiler. Since you can not modify this upper limit in the compiler, my guess is that the only solution is to break it apart.

Curious, how many lines of code are in this "large" sub?
 
Upvote 0

Nicolás Cieri

Active Member
Licensed User
If I use the legacy debugger, everything works, the problem is that the development of the app is much slower.

This sub is with 1224 lines (The same as in B4i works perfectly.).
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
You could try breaking your try block into smaller blocks:
B4X:
Try
    .. .code
   … code
Catch
    Error=True
    HandleError
End Try
' next step
If Not(Error) Then
    Try
      ..code
      ..code
  Catch
       Error = True
      HandleError
   End Try
End If
' And so on...
You can even eliminate the "If Not(Error)" if every catch block ends with a Return statement.
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
In that case, I'd listen to @Erel:
 
Upvote 0

Nicolás Cieri

Active Member
Licensed User
It is not that, it is not the time that it can take me ... if it is a well done and well structured code, I think that the system should not have that limitation.

But hey ... for now, although it will take much longer, I will use the legacy debugger.

Thanks anyway Erel.
 
Upvote 0
Top