You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error response when invoking call functions which throw appears to different depending on the data source in use, and whether running in the browser or under Node.js.
Using a model with an HttpDataSource in the browser (Chrome 62):
constmodel=newfalcor.Model({// Note that the Express app hosting the `falcor-express` instance has error-handling// middleware returning a JSON representation of the errorsource: newHttpDataSource('http://localhost:3000/model.json')});// Prints:// *** err instanceof Error: true// *** err.message: "[object Object]"
Using a model with an HttpDataSource under Node.js (v6.11.1):
constmodel=newfalcor.Model({source: newHttpDataSource('http://localhost:3000/model.json')});// Prints:// *** err instanceof Error: true// *** err.message: [JSON stringified version of the full error object]
Using a model with the router itself as a datasource under Node.js:
There seems to be a slight inconsistency in error handling between the way HttpDataSource handles JSON error responses in the browser vs. on Node.js. Additionally using the router directly as a data source has entirely different behavior (which couldn't be replicated over an HTTP interface unless we could guarantee the availability of any custom error subclasses on the client).
I'm left with a few questions:
Are there plans for a consistent error representation that is datasource-independent, so that application code can handle errors without needing to know the specifics of how the model is wired to the router?
What is the recommended method for propagating actionable/user-facing errors from call operations to consumers of the Model? For example: 'email already in use' while calling signup or 'invalid password' when calling login
The text was updated successfully, but these errors were encountered:
can you provide code that's supposed to go here: { /* examine err */}?
falcor does not treat errors in browser vs node.js any differently, but those platforms themselves can and do print objects to console differently. that could be one potential reason why you're seeing errors printed differently in browser vs node.js
in any case, do provide how you're printing the errors, it may hold some clue :)
a good way to propagate errors from router to client is simply to return { "$type": "error", value: "Error message" } as the value of appropriate elements in your JSON Graph.
Does that answer your question?
The error response when invoking
call
functions whichthrow
appears to different depending on the data source in use, and whether running in the browser or under Node.js.Given the following
call
usage:Using a model with an
HttpDataSource
in the browser (Chrome 62):Using a model with an
HttpDataSource
under Node.js (v6.11.1):Using a model with the router itself as a datasource under Node.js:
There seems to be a slight inconsistency in error handling between the way
HttpDataSource
handles JSON error responses in the browser vs. on Node.js. Additionally using the router directly as a data source has entirely different behavior (which couldn't be replicated over an HTTP interface unless we could guarantee the availability of any custom error subclasses on the client).I'm left with a few questions:
call
operations to consumers of the Model? For example: 'email already in use' while callingsignup
or 'invalid password' when callinglogin
The text was updated successfully, but these errors were encountered: