mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:46:38 +00:00
chore: catch error when create datasource (#5514)
This commit is contained in:
parent
056728d7ab
commit
3ccfc89960
@ -92,34 +92,34 @@ export class DataSourceModel extends Model {
|
||||
const type = this.get('type');
|
||||
const createOptions = this.get('options');
|
||||
|
||||
const dataSource = app.dataSourceManager.factory.create(type, {
|
||||
...createOptions,
|
||||
name: dataSourceKey,
|
||||
logger: app.logger.child({ dataSourceKey }),
|
||||
sqlLogger: app.sqlLogger.child({ dataSourceKey }),
|
||||
});
|
||||
|
||||
if (loadAtAfterStart) {
|
||||
dataSource.on('loadMessage', ({ message }) => {
|
||||
app.setMaintainingMessage(`${message} in data source ${this.get('displayName')}`);
|
||||
});
|
||||
}
|
||||
|
||||
const acl = dataSource.acl;
|
||||
|
||||
for (const [actionName, actionParams] of Object.entries(availableActions)) {
|
||||
acl.setAvailableAction(actionName, actionParams);
|
||||
}
|
||||
|
||||
acl.allow('*', '*', (ctx) => {
|
||||
return ctx.state.currentRole === 'root';
|
||||
});
|
||||
|
||||
dataSource.resourceManager.use(setCurrentRole, { tag: 'setCurrentRole', before: 'acl', after: 'auth' });
|
||||
|
||||
await this.loadIntoACL({ app, acl, transaction: options.transaction });
|
||||
|
||||
try {
|
||||
const dataSource = app.dataSourceManager.factory.create(type, {
|
||||
...createOptions,
|
||||
name: dataSourceKey,
|
||||
logger: app.logger.child({ dataSourceKey }),
|
||||
sqlLogger: app.sqlLogger.child({ dataSourceKey }),
|
||||
});
|
||||
|
||||
if (loadAtAfterStart) {
|
||||
dataSource.on('loadMessage', ({ message }) => {
|
||||
app.setMaintainingMessage(`${message} in data source ${this.get('displayName')}`);
|
||||
});
|
||||
}
|
||||
|
||||
const acl = dataSource.acl;
|
||||
|
||||
for (const [actionName, actionParams] of Object.entries(availableActions)) {
|
||||
acl.setAvailableAction(actionName, actionParams);
|
||||
}
|
||||
|
||||
acl.allow('*', '*', (ctx) => {
|
||||
return ctx.state.currentRole === 'root';
|
||||
});
|
||||
|
||||
dataSource.resourceManager.use(setCurrentRole, { tag: 'setCurrentRole', before: 'acl', after: 'auth' });
|
||||
|
||||
await this.loadIntoACL({ app, acl, transaction: options.transaction });
|
||||
|
||||
await app.dataSourceManager.add(dataSource, {
|
||||
localData: await this.loadLocalData(),
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user