Skip to content
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

Use strings for error codes #115

Open
alecgibson opened this issue May 18, 2021 · 1 comment
Open

Use strings for error codes #115

alecgibson opened this issue May 18, 2021 · 1 comment
Milestone

Comments

@alecgibson
Copy link
Contributor

We should use Node-style error codes to be consistent with sharedb.

@alecgibson alecgibson added this to the v1.0 milestone May 18, 2021
@ericyhwang
Copy link
Contributor

Error codes for sharedb-mongo:

sharedb-mongo/index.js

Lines 1551 to 1618 in 2287e66

// Bad request errors
ShareDbMongo.invalidOpVersionError = function(collectionName, id, v) {
return {
code: 4101,
message: 'Invalid op version ' + collectionName + '.' + id + ' ' + v
};
};
ShareDbMongo.invalidCollectionError = function(collectionName) {
return {code: 4102, message: 'Invalid collection name ' + collectionName};
};
ShareDbMongo.$whereDisabledError = function() {
return {code: 4103, message: '$where queries disabled'};
};
ShareDbMongo.$mapReduceDisabledError = function() {
return {code: 4104, message: '$mapReduce queries disabled'};
};
ShareDbMongo.$aggregateDisabledError = function() {
return {code: 4105, message: '$aggregate queries disabled'};
};
ShareDbMongo.$queryDeprecatedError = function() {
return {code: 4106, message: '$query property deprecated in queries'};
};
ShareDbMongo.malformedQueryOperatorError = function(operator) {
return {code: 4107, message: 'Malformed query operator: ' + operator};
};
ShareDbMongo.onlyOneCollectionOperationError = function(operation1, operation2) {
return {
code: 4108,
message: 'Only one collection operation allowed. ' +
'Found ' + operation1 + ' and ' + operation2
};
};
ShareDbMongo.onlyOneCursorOperationError = function(operation1, operation2) {
return {
code: 4109,
message: 'Only one cursor operation allowed. ' +
'Found ' + operation1 + ' and ' + operation2
};
};
ShareDbMongo.cursorAndCollectionMethodError = function(collectionOperation) {
return {
code: 4110,
message: 'Cursor methods can\'t run after collection method ' +
collectionOperation
};
};
// Internal errors
ShareDbMongo.alreadyClosedError = function() {
return {code: 5101, message: 'Already closed'};
};
ShareDbMongo.missingLastOperationError = function(collectionName, id) {
return {
code: 5102,
message: 'Snapshot missing last operation field "_o" ' + collectionName + '.' + id
};
};
ShareDbMongo.missingOpsError = function(collectionName, id, from) {
return {
code: 5103,
message: 'Missing ops from requested version ' + collectionName + '.' + id + ' ' + from
};
};
// Modifies 'err' argument
ShareDbMongo.parseQueryError = function(err) {
err.code = 5104;
return err;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants