iOS Question B4i Try Catch Not Catching? [SOLVED]

mmieher

Active Member
Licensed User
Longtime User
What am I doing wrong here? This attempt to catch an error, actually crashes the App AND executes the statement in the Catch area.

B4X:
    436        Dim tPic As String = qMap.Get("picfile")
    437        Try
    438            Dim bm As Bitmap = LoadBitmap(Main.Dir, Main.AppDir & "Images/MenuThumbs/" & tPic)
    439            ivProduct.Bitmap = bm
    440        Catch
    441            Marc.mLog("ERR","Error on MenuThumb = " & tPic)
    442        End Try

Log: (scroll to bottom for Catch text)
inItem = 179
ExecuteMemoryTable: SELECT sizes.unit, sizes.regprice, sizes.idsize FROM itemxref itemxref, sizes sizes WHERE itemxref.idtrait = sizes.idsize And itemxref.xtype='S' AND itemxref.iditem = 179 ORDER BY sizes.regprice
ExecuteMemoryTable: SELECT * FROM reviews WHERE iditem = 179
ExecuteMemoryTable: SELECT * FROM pictures WHERE iditem = 179
Error occurred on line: 438 (DS)
Error opening stream (/var/mobile/Containers/Data/Application/54497C10-525F-4F67-A285-767DFEAEA399/Documents/ShopperMenu/MindRite/Images/MenuThumbs/MR-test.png): Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory" UserInfo={_kCFStreamErrorCodeKey=2, _kCFStreamErrorDomainKey=1}
Stack Trace: (
CoreFoundation <redacted> + 252
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation <redacted> + 0
ShopperMenu -[B4IFile OpenInput::] + 440
ShopperMenu -[B4IBitmap Initialize::] + 796
ShopperMenu -[B4ICommon LoadBitmap::] + 136
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 292
ShopperMenu +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
ShopperMenu -[B4IShell runMethod:] + 448
ShopperMenu -[B4IShell raiseEventImpl:method:args::] + 1648
ShopperMenu -[B4IShellBI raiseEvent:event:params:] + 1580
ShopperMenu +[B4IDebug delegate:::] + 80
ShopperMenu -[b4i_ds _createitemlistitem::::::] + 760
ShopperMenu -[b4i_ds _displayproductmenu] + 5740
ShopperMenu -[ResumableSub_ds_StartDS resume::] + 2456
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 292
ShopperMenu +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
ShopperMenu -[B4IShell runMethod:] + 448
ShopperMenu -[B4IShell raiseEventImpl:method:args::] + 2172
ShopperMenu -[B4IShellBI raiseEvent:event:params:] + 1580
ShopperMenu -[B4IDelegatableResumableSub resume::] + 380
ShopperMenu -[B4I checkAndRunWaitForEvent:event:params:] + 552
ShopperMenu -[B4IShellBI raiseEvent:event:params:] + 1436
ShopperMenu __37-[B4ICommon ReturnFromResumableSub::]_block_invoke + 368
libdispatch.dylib <redacted> + 24
libdispatch.dylib <redacted> + 16
libdispatch.dylib <redacted> + 1068
CoreFoundation <redacted> + 12
CoreFoundation <redacted> + 1964
CoreFoundation CFRunLoopRunSpecific + 436
GraphicsServices GSEventRunModal + 100
UIKitCore UIApplicationMain + 212
ShopperMenu main + 124
libdyld.dylib <redacted> + 4
)
Error on MenuThumb = MR-test.png
inItem = 180
 
D

Deleted member 103

Guest
Are you sure that this folder exists?
/var/mobile/Containers/Data/Application/54497C10-525F-4F67-A285-767DFEAEA399/Documents/ShopperMenu/MindRite/Images/MenuThumbs
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
Yes, I am. Many other of my items have images there. One item image is missing. That is a problem, but the Try/Catch should prevent the App from crashing.
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
After the post, I had some other strange behavior. I uninstalled the App from the phone, rebuilt the B4i-Bridge, and now all is fine. Thanks for the replies.
 
Upvote 0
Top