webPushFailureReason function
A readable explanation for a push service rejection.
Push services answer with a status and little else, and the statuses that matter mean different things here than they do elsewhere — a 410 is not a missing page, it is an instruction to stop sending to this subscription forever.
Implementation
String webPushFailureReason(DVHttpResponse response) {
return switch (response.statusCode) {
404 || 410 =>
'The subscription is gone: the user revoked permission or cleared site '
'data. Delete it rather than retrying.',
413 =>
'Payload too large. A push service guarantees only 4KB of encrypted '
'payload.',
429 => 'Rate limited by the push service. Honour Retry-After.',
401 || 403 =>
'VAPID rejected: the signature, the subject, or the key does not match '
'the one the browser subscribed with.',
_ => 'The push service rejected the notification.',
};
}