mirror of https://gitee.com/bigwinds/arangodb
improve graph error messages in the UI (#6368)
This commit is contained in:
parent
72532ca24a
commit
87e4f455d6
|
@ -31,12 +31,15 @@ const joi = require('joi');
|
||||||
const dd = require('dedent');
|
const dd = require('dedent');
|
||||||
const internal = require('internal');
|
const internal = require('internal');
|
||||||
const db = require('@arangodb').db;
|
const db = require('@arangodb').db;
|
||||||
|
const actions = require('@arangodb/actions');
|
||||||
const errors = require('@arangodb').errors;
|
const errors = require('@arangodb').errors;
|
||||||
|
const ArangoError = require('@arangodb').ArangoError;
|
||||||
const notifications = require('@arangodb/configuration').notifications;
|
const notifications = require('@arangodb/configuration').notifications;
|
||||||
const examples = require('@arangodb/graph-examples/example-graph');
|
const examples = require('@arangodb/graph-examples/example-graph');
|
||||||
const createRouter = require('@arangodb/foxx/router');
|
const createRouter = require('@arangodb/foxx/router');
|
||||||
const users = require('@arangodb/users');
|
const users = require('@arangodb/users');
|
||||||
const cluster = require('@arangodb/cluster');
|
const cluster = require('@arangodb/cluster');
|
||||||
|
const generalGraph = require('@arangodb/general-graph');
|
||||||
const request = require('@arangodb/request');
|
const request = require('@arangodb/request');
|
||||||
const isEnterprise = require('internal').isEnterprise();
|
const isEnterprise = require('internal').isEnterprise();
|
||||||
const explainer = require('@arangodb/aql/explainer');
|
const explainer = require('@arangodb/aql/explainer');
|
||||||
|
@ -340,8 +343,17 @@ authRouter.post('/graph-examples/create/:name', function (req, res) {
|
||||||
if (['knows_graph', 'social', 'routeplanner', 'traversalGraph', 'mps_graph', 'worldCountry'].indexOf(name) === -1) {
|
if (['knows_graph', 'social', 'routeplanner', 'traversalGraph', 'mps_graph', 'worldCountry'].indexOf(name) === -1) {
|
||||||
res.throw('not found');
|
res.throw('not found');
|
||||||
}
|
}
|
||||||
|
if (generalGraph._list().indexOf(name) !== -1) {
|
||||||
const g = examples.loadGraph(name);
|
const error = new ArangoError({errorNum: errors.ERROR_GRAPH_DUPLICATE.code, errorMessage: errors.ERROR_GRAPH_DUPLICATE.message});
|
||||||
|
res.throw(409, error);
|
||||||
|
}
|
||||||
|
let g = false;
|
||||||
|
try {
|
||||||
|
g = examples.loadGraph(name);
|
||||||
|
} catch (e) {
|
||||||
|
const error = new ArangoError({errorNum: e.errorNum, errorMessage: e.errorMessage});
|
||||||
|
res.throw(actions.arangoErrorToHttpCode(e.errorNum), error);
|
||||||
|
}
|
||||||
res.json({error: !g});
|
res.json({error: !g});
|
||||||
})
|
})
|
||||||
.pathParam('name', joi.string().required(), 'Name of the example graph.')
|
.pathParam('name', joi.string().required(), 'Name of the example graph.')
|
||||||
|
|
Loading…
Reference in New Issue