-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server to client error messages #1406
base: main
Are you sure you want to change the base?
Conversation
@@ -582,6 +583,8 @@ defmodule Electric.Satellite.Serialization do | |||
_ = Date.from_iso8601!(val) | |||
|
|||
val | |||
rescue | |||
_ -> raise DataValidationError, message: "Unexpected value for :date column: #{inspect(val)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ignores the specific error message from any of the function calls above and substitutes that with this generic message. That's not a problem, IMO, but then we don't need those extra catch-all clauses you added below, such as Month our of range
and others.
Also, this needs to be a reraise
to preserve the original stacktrace:
_ -> raise DataValidationError, message: "Unexpected value for :date column: #{inspect(val)}" | |
_ -> reraise DataValidationError, [message: "Unexpected value for :date column: #{inspect(val)}"], __STACKTRACE__ |
|
||
val | ||
_ -> | ||
raise DataValidationError, message: "Non integer value given for #{type} column: #{val}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise DataValidationError, message: "Non integer value given for #{type} column: #{val}" | |
raise DataValidationError, message: "Non-integer value given for #{type} column: #{val}" |
@@ -621,36 +633,68 @@ defmodule Electric.Satellite.Serialization do | |||
_ = Time.from_iso8601!(val) | |||
|
|||
val | |||
rescue | |||
_ -> raise DataValidationError, message: "Unexpected value for :time column: #{inspect(val)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same considerations as for the other use of rescue
above apply here
_ -> raise DataValidationError, message: "Unexpected value for :time column: #{inspect(val)}" | |
_ -> reraise DataValidationError, [message: "Unexpected value for :time column: #{inspect(val)}"], __STACKTRACE_ |
Minor comment but i think the error that is displayed on the client should make very clear that this is a server-side error, otherwise it will confuse people and they will think there is a problem with the client. |
https://linear.app/electric-sql/issue/VAX-1983/improve-error-reporting-from-server-to-client
This PR add the ability of the client to show friendly error messages when the error has originated on the server.
For example:
At this stage I've not tried to hide any noise such as the stack trace in these scenarios. So the user in fact sees all of this:
I've also added friendly error message generation on the server for data validation errors as an example of how you would implement the friendly error messages. Once the permissions system has been added, rejected writes could also generate a friendly error message in a similar way.
The client will now also see error messages that were already being set in the SatErrorResp such as: