-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
what
Add a way to catch (/subscribe) and act upon errors, especially for errors coming from the server.
Something like this:
db.get('users').get('420').get('name').set(3).catch((e) => {
console.log(e);
// -> { name: 'plugin:validation:invalidType', path: '/users/420/name', message: 'Property name has to be a string.' }
});Error paths should be subscribed to like any other path. So they are only send to the client, if they are subscribed.
To always subscribe to errors and log them in the console automatically, we could introduce a config parameter:
SocketDBClient({
url: 'ws://localhost:3000',
alwaysLogErrors: true
});Errors should have a few properties to be useful, e.g.:
type Error = {
// unique name, that can be scoped using a colon. ":". Plugins are scoped by their name.
name: string;
// socketdb path, where the error occured.
path: string;
// human-readable error message that might be displayed to the user
message: string;
}Example error:
const error: Error = {
name: 'plugin:permissions:accessDenied',
path: '/users/1/name',
message: 'You do not have permission to access this data.'
}Or maybe splitting context and name?
const error: Error = {
context: 'server:plugin:permissions',
name 'accessDenied',
path: '/users/1/name',
message: 'You do not have permission to access this data.'
}why
Currently, when an update is rejected from the server, there is no way to know the reason on the client side. → It is rejected silently.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request