w3c / secure-payment-confirmation

Secure Payment Confirmation (SPC)
https://w3c.github.io/secure-payment-confirmation/
Other
106 stars 48 forks source link

Error example contains a hardcoded string #206

Closed aphillips closed 1 year ago

aphillips commented 1 year ago

section 1.2.2 https://www.w3.org/TR/secure-payment-confirmation/#sctn-sample-authentication

  if (!canMakePayment) { throw new Error('Cannot make payment'); }

Here is an example that includes a hardcoded string. This is probably fine as "merely an example". JS doesn't currently provide an in-built localization solution and there are plenty of libraries and frameworks that developers use to accomplish localization. The hardcoded string makes the example clear. I18N and our specdev checklist should probably have better guidance on how to handle H/C strings or maybe a note about them.

We expect you'll probably close this issue, but you might consider adding a code comment about the I18N bug represented by the static message, e.g.:

if ( ! canMakePayment ) {
    // string hardcoded for clarity
   throw new Error('Cannot make payment');
}
ianbjacobs commented 1 year ago

@aphillips, based on discussion at TPAC with @stephenmcgruer, I think we will remove the hardcoded string and just put a comment that the developer needs to handle the error case.