Hi, I use background for my data field to make web requests. Im updating an old Data field to use a barrel for the web requests (as I want to share the same code base across multiple apps/data fields). I have put the (:background) annotation in the barrel module so that should not be the issue I think. Before I did that I got the same error message when I made the call to a function in the barrel, but that went away after I added the background annotation to the barrel module.
Here is part of my source code for the BG process: The runtime error occurs when I make the Background.exit(_data) call, to pass the data to the foreground. I get the following in my console:
Error: Illegal Access (Out of Bounds)
Details: Failed invoking <symbol>
using my_barrel;
(:background)
class myBGclass extends Toybox.System.ServiceDelegate {
function initialize() {
System.ServiceDelegate.initialize();
}
function readResponse(data, responseCode) {
var _data = {};
_data["ResponseCode"] = responseCode;
if (responseCode == 200) {
//copy selected entries from data to _data here
}
Background.exit(_data);
}
function onTemporalEvent() {
// call to makerequest in my_barrel
my_barrel.makerequest(URL, method(:readResponse));
}
}