Logging error will no longer exit node program
This commit is contained in:
parent
7ebc0450b6
commit
7c65907f21
@ -27,7 +27,7 @@ export class Engine {
|
||||
if (dbModel.entities.length > 0) {
|
||||
this.createModelFromMetadata(dbModel);
|
||||
} else {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
"Tables not found in selected database. Skipping creation of typeorm model.",
|
||||
false
|
||||
);
|
||||
|
@ -1,20 +1,19 @@
|
||||
import * as data from "./../../package.json";
|
||||
export function LogFatalError(
|
||||
export function LogError(
|
||||
errText: string,
|
||||
isABug: boolean = true,
|
||||
errObject?: any
|
||||
) {
|
||||
let x = <any>data;
|
||||
console.error(errText);
|
||||
console.error(`Fatal error occured.`);
|
||||
console.error(`Error occured in typeorm-model-generator.`);
|
||||
console.error(`${x.name}@${x.version} node@${process.version}`);
|
||||
console.error(`Fatal error occured in typeorm-model-generator.`);
|
||||
console.error(
|
||||
`If this is a bug please open an issue including this log on ${
|
||||
`If you think this is a bug please open an issue including this log on ${
|
||||
x.bugs.url
|
||||
}`
|
||||
);
|
||||
if (isABug && !errObject) errObject = new Error().stack;
|
||||
if (!!errObject) console.error(errObject);
|
||||
process.abort();
|
||||
// process.abort();
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ export abstract class AbstractDriver {
|
||||
dbModel.entities.forEach(entity => {
|
||||
let primaryIndex = entity.Indexes.find(v => v.isPrimaryKey);
|
||||
if (!primaryIndex) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Table ${entity.EntityName} has no PK.`,
|
||||
false
|
||||
);
|
||||
|
@ -217,7 +217,7 @@ export class MssqlDriver extends AbstractDriver {
|
||||
colInfo.ts_type = "string";
|
||||
break;
|
||||
default:
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Unknown column type: ${
|
||||
resp.DATA_TYPE
|
||||
} table name: ${
|
||||
@ -363,7 +363,7 @@ order by
|
||||
return entitity.EntityName == relationTmp.ownerTable;
|
||||
});
|
||||
if (!ownerEntity) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity model ${relationTmp.ownerTable}.`
|
||||
@ -374,7 +374,7 @@ order by
|
||||
return entitity.EntityName == relationTmp.referencedTable;
|
||||
});
|
||||
if (!referencedEntity) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity model ${relationTmp.referencedTable}.`
|
||||
@ -385,7 +385,7 @@ order by
|
||||
return column.name == relationTmp.ownerColumnsNames[0];
|
||||
});
|
||||
if (!ownerColumn) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity column ${
|
||||
@ -398,7 +398,7 @@ order by
|
||||
return column.name == relationTmp.referencedColumnsNames[0];
|
||||
});
|
||||
if (!relatedColumn) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity column ${
|
||||
@ -517,7 +517,7 @@ order by
|
||||
//Connection successfull
|
||||
resolve(true);
|
||||
} else {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
"Error connecting to MSSQL Server.",
|
||||
false,
|
||||
err.message
|
||||
|
@ -210,7 +210,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
.replace(/\'/gi, '"');
|
||||
break;
|
||||
default:
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Unknown column type: ${
|
||||
resp.DATA_TYPE
|
||||
} table name: ${
|
||||
@ -326,7 +326,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
return entitity.EntityName == relationTmp.ownerTable;
|
||||
});
|
||||
if (!ownerEntity) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity model ${relationTmp.ownerTable}.`
|
||||
@ -337,7 +337,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
return entitity.EntityName == relationTmp.referencedTable;
|
||||
});
|
||||
if (!referencedEntity) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity model ${relationTmp.referencedTable}.`
|
||||
@ -348,7 +348,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
return column.name == relationTmp.ownerColumnsNames[0];
|
||||
});
|
||||
if (!ownerColumn) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity column ${
|
||||
@ -361,7 +361,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
return column.name == relationTmp.referencedColumnsNames[0];
|
||||
});
|
||||
if (!relatedColumn) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity column ${
|
||||
@ -456,7 +456,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
//Connection successfull
|
||||
resolve(true);
|
||||
} else {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Error disconnecting to ${this.EngineName} Server.`,
|
||||
false,
|
||||
err.message
|
||||
@ -508,7 +508,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
//Connection successfull
|
||||
resolve(true);
|
||||
} else {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Error connecting to ${this.EngineName} Server.`,
|
||||
false,
|
||||
err.message
|
||||
|
@ -17,7 +17,7 @@ export class OracleDriver extends AbstractDriver {
|
||||
try {
|
||||
this.Oracle = require("oracledb");
|
||||
} catch (error) {
|
||||
TomgUtils.LogFatalError("", false, error);
|
||||
TomgUtils.LogError("", false, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@ export class OracleDriver extends AbstractDriver {
|
||||
resp[5] > 0 ? resp[5] : null;
|
||||
break;
|
||||
default:
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
"Unknown column type:" + resp[4]
|
||||
);
|
||||
break;
|
||||
@ -164,7 +164,7 @@ export class OracleDriver extends AbstractDriver {
|
||||
return entitity.EntityName == relationTmp.ownerTable;
|
||||
});
|
||||
if (!ownerEntity) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity model ${relationTmp.ownerTable}.`
|
||||
@ -175,7 +175,7 @@ export class OracleDriver extends AbstractDriver {
|
||||
return entitity.EntityName == relationTmp.referencedTable;
|
||||
});
|
||||
if (!referencedEntity) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity model ${relationTmp.referencedTable}.`
|
||||
@ -186,7 +186,7 @@ export class OracleDriver extends AbstractDriver {
|
||||
return column.name == relationTmp.ownerColumnsNames[0];
|
||||
});
|
||||
if (!ownerColumn) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity column ${
|
||||
@ -199,7 +199,7 @@ export class OracleDriver extends AbstractDriver {
|
||||
return column.name == relationTmp.referencedColumnsNames[0];
|
||||
});
|
||||
if (!relatedColumn) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity column ${
|
||||
@ -316,7 +316,7 @@ export class OracleDriver extends AbstractDriver {
|
||||
that.Connection = connection;
|
||||
resolve(true);
|
||||
} else {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
"Error connecting to Oracle Server.",
|
||||
false,
|
||||
err.message
|
||||
|
@ -188,7 +188,7 @@ export class PostgresDriver extends AbstractDriver {
|
||||
colInfo.ts_type = "string";
|
||||
break;
|
||||
default:
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Unknown column type: ${
|
||||
resp.data_type
|
||||
} table name: ${
|
||||
@ -350,7 +350,7 @@ export class PostgresDriver extends AbstractDriver {
|
||||
return entitity.EntityName == relationTmp.ownerTable;
|
||||
});
|
||||
if (!ownerEntity) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity model ${relationTmp.ownerTable}.`
|
||||
@ -361,7 +361,7 @@ export class PostgresDriver extends AbstractDriver {
|
||||
return entitity.EntityName == relationTmp.referencedTable;
|
||||
});
|
||||
if (!referencedEntity) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity model ${relationTmp.referencedTable}.`
|
||||
@ -372,7 +372,7 @@ export class PostgresDriver extends AbstractDriver {
|
||||
return column.name == relationTmp.ownerColumnsNames[0];
|
||||
});
|
||||
if (!ownerColumn) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity column ${
|
||||
@ -385,7 +385,7 @@ export class PostgresDriver extends AbstractDriver {
|
||||
return column.name == relationTmp.referencedColumnsNames[0];
|
||||
});
|
||||
if (!relatedColumn) {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity column ${
|
||||
@ -481,7 +481,7 @@ export class PostgresDriver extends AbstractDriver {
|
||||
//Connection successfull
|
||||
resolve(true);
|
||||
} else {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
"Error connecting to Postgres Server.",
|
||||
false,
|
||||
err.message
|
||||
@ -517,7 +517,7 @@ export class PostgresDriver extends AbstractDriver {
|
||||
//Connection successfull
|
||||
resolve(true);
|
||||
} else {
|
||||
TomgUtils.LogFatalError(
|
||||
TomgUtils.LogError(
|
||||
"Error connecting to Postgres Server.",
|
||||
false,
|
||||
err.message
|
||||
|
@ -107,7 +107,7 @@ switch (argv.e) {
|
||||
standardPort = 1521;
|
||||
break;
|
||||
default:
|
||||
TomgUtils.LogFatalError("Database engine not recognized.", false);
|
||||
TomgUtils.LogError("Database engine not recognized.", false);
|
||||
throw new Error("Database engine not recognized.");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user