update error messages:
This commit is contained in:
parent
fed6a83bca
commit
87768fd577
|
@ -5,9 +5,20 @@ const mysqlErrorMessages: Record<number, string> = {
|
|||
1049: "The specified database does not exist. Please verify that the database name is correct.",
|
||||
}
|
||||
|
||||
const postgresErrorMessages: Record<number, string> = {}
|
||||
const postgresErrorMessages: Record<string, string> = {
|
||||
"23505": "Duplicate key value violates unique constraint.",
|
||||
"23502": "Null value not allowed for a column.",
|
||||
"23503": "Foreign key violation.",
|
||||
"23514": "Check constraint violation.",
|
||||
"42703": "Undefined column.",
|
||||
"42P01": "Undefined table.",
|
||||
}
|
||||
|
||||
const sqlServerErrorMessages: Record<number, string> = {}
|
||||
const sqlServerErrorMessages: Record<number, string> = {
|
||||
547: "The INSERT statement conflicted with the FOREIGN KEY constraint.",
|
||||
2601: "Cannot insert duplicate key row in object.",
|
||||
515: "Cannot insert the value NULL into column.",
|
||||
}
|
||||
|
||||
export const getReadableErrorMessage = (type: string, errno: number) => {
|
||||
switch (type) {
|
||||
|
|
|
@ -182,7 +182,7 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
|
|||
} catch (err: any) {
|
||||
let readableMessage = getReadableErrorMessage(
|
||||
SourceName.SQL_SERVER,
|
||||
err.errno
|
||||
err.number
|
||||
)
|
||||
if (readableMessage) {
|
||||
throw new Error(readableMessage)
|
||||
|
|
|
@ -247,7 +247,7 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
|||
await this.closeConnection()
|
||||
let readableMessage = getReadableErrorMessage(
|
||||
SourceName.POSTGRES,
|
||||
err.errno
|
||||
err.code
|
||||
)
|
||||
if (readableMessage) {
|
||||
throw new Error(readableMessage)
|
||||
|
|
Loading…
Reference in New Issue