FYI all of these are using exact paths, I think you probably meant to append a * at the end of each path (or for the first one, i.e. /, just omit the / entirely).
The closest equivalent of this to v2 is something like this:
handle_errors {
root * /data/mastodon/public
rewrite 500.html
file_server
}
Might not work exactly the same way but it should at least serve 500.html if there’s any 4xx or 5xx error.