Thanks, adnzzzzZ!
Good point, it's worth mentioning that these exist
AWS also has a free tier
https://aws.amazon.com/free/
airstruck wrote: ↑Thu May 04, 2017 1:32 pm
bartbes wrote:It could work, but it's likely easier to set up a web page you can just POST the message to.
That might be easier if you already have a web server set up, with a domain pointed at it, and a database installed. [...]
Setting all that stuff up for the first time (and writing those scripts, if they don't ship with the library) will almost certainly not be easier than signing up for a free email account, adding a forwarding rule or filter, and configuring the crash handler with an email address and MX server.
I agree with airstruck here. It's true that the stuff you'd need to set up isn't very complex, but you do need the infrastructure, you do need some basic knowledge about how to set up a database and a little web server that accepts your crash reports and so on. These things add up, and all of the sudden you spend days worrying about this stuff instead of working on your game.
It would be great if someone wrote a library that solved all of these problems, and for larger projects I totally agree that you're probably better off writing your own little server that you can tweak to your needs. But I do think that the email approach has its place. What I find very powerful about Love is how easy it is to get started. It just takes a few lines of code to draw something, and after a few more lines you can move that thing with WASD. The learning curve is very shallow, what makes it approachable to newcomers.
If there is a reliable way to submit crash reports via email, then this would fall in line with that paradigm; all you'd need to collect crash reports is an email address.
So, I went ahead and extracted the error handler code into a separate module,
crush. Its API consists of these functions (and a few others that are less interesting):
Code: Select all
function crush.report_automatically(error_message, recipient, smtp_config, extra_info, stack_offset)
tries to automatically submit the crash report to the given recipient via email, using the server and port provided in smtp_config. extra_info (optional) is a key-value table containing any additional information you want to include (e.g. version, operating system, current level etc), and stack_offset (optional) can be used to skip some items of the traceback (like love.errhand).
Code: Select all
function crush.report_manually(error_message, recipient, extra_info, stack_offset)
asks the user to submit the crash report manually (using the mailto URL). All arguments have the same meaning as in report_automatically.
You can also attach files (e.g. a log file) when using the automatic report (As far as I know that's not possible with the mailto URL).
If the automatic report fails, it will ask the user to submit the report manually.
Here is how you'd use it:
Code: Select all
local crush = require("crush")
function love.draw() love.graphics.print("Click to provoke an error") end
function love.mousepressed() error("intended crash") end
function love.errhand(error_message)
crush.pcall(function() -- Wrap your error handling code in crush.pcall for extra protection.
local recipient = "your@email.com"
local smtp_config = {server = "server.com", port = 587}
local extra_info = {
Version = "0.8.3-rc1",
OS = love.system.getOS(),
_files = { -- special key for file attachments
"some/file.jpg",
{
mimetype = "text/plain",
filename = "another/file.txt"
}
}
}
crush.report_automatically(error_message, recipient, smtp_config, extra_info, 3)
-- crush.report_manually(error_message, recipient, extra_info, 3)
end)
end
I wouldn't worry about SPF and DKIM, either it works reliably with a given email service or it doesn't, you can expect the user will want to filter/forward it anyway, so it would just be a matter of recommending a few email services that are known to work.
I did get it to work via gmail, surprisingly. Google has different SMTP servers for different scenarios (
https://support.google.com/a/answer/176600?hl=en), and aspmx.l.google.com doesn't require TLS. So, if you use "<
your.address@gmail.com>" (the angular brackets are necessary) as recipient, and "aspmx.l.google.com" as server on port 25, then it should work.
I'd be super grateful if a few people could verify from their computer that this works. Maybe it does turn out to be unreliable or inconsistent.
Unfortunately I had no luck with any of the traditional email providers (so far I tried yahoo.com, mail.com and gmx.net), but maybe I just didn't test the right settings. My IP was also temporarily blacklisted (probably because I tinkered around too much with servers and ports and so on), which also caused gmail to drop some of my requests. I was able to send again a few hours later though, and I haven't had any problems since then.
I've attached two files, crush.lua contains only the crush module, and crush-test.love is basically the usage example above.
You will need to change the recipient email address in main.lua to try it out. If you're asked to submit the crash report manually, then the automatic submission failed. This is the fallback method I mentioned above. You can check the console for the error message to see why it failed.