suddjian edited a comment on issue #9194: [SIP-40] Proposal for Custom Error 
Messages
URL: 
https://github.com/apache/incubator-superset/issues/9194#issuecomment-590599304
 
 
   I love it! Been wanting to address this for a while, so thank you. I have 
some questions/suggestions.
   
   How should translation fit into this? Error messages are sometimes written 
to have dynamic values contained in them, such as `"{input}" is not a valid 
url`, or `{some_resource} is already in use`. Do we only allow static error 
messages? Is there a way for dynamic error messages to play well with the 
translation system? Dynamic error messages can often make a big difference in 
UX: it can be tricky to write static messages that accurately describe every 
situation where you might see the error.
   
   I lean towards a system where the text of the error message is defined 
entirely on the frontend, with the error object containing parameters with 
which to construct a message. It makes sense for the backend to supply an error 
message for debugging purposes, but that field should indicate that it's not 
meant to be used in UI.
   
   I'd also like form validation errors to have a standard schema, so that the 
frontend can display validation errors in the appropriate place in the UI. 
Since we seem to be going towards having an array of error objects, we could 
attach a `field_name` value to an error when it relates to a specific field. So 
if a hypothetical url field called `custom_url` was submitted with a bad value, 
you'd get back:
   
   ```json
   {
    "errors": [{
       "error_type": "INPUT_INVALID_URL",
       "level": "error",
       "debug_message": "Invalid url value for custom_url",
       "field_name": "custom_url",
       "message_params": {
         "input": "https//notvalid"
       }
     }]
   }
   ```
   
   ~Lastly, I could use some clarification: what's the purpose of allowing 
admins to override the renderer?~ Nevermind, I get it now - it's just for the 
generic messages, that makes sense.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to