pganalyzer

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = func(err error) dberrors.ErrType {
	if err == sql.ErrNoRows {
		return dberrors.DoesNotExist
	}
	pgErr, ok := err.(*pq.Error)
	if !ok {
		return dberrors.Other
	}

	if pgErr.Code.Name() == "unique_violation" {
		return dberrors.AlreadyExists
	}

	if pgErr.Code.Class().Name() == "integrity_constraint_violation" {
		return dberrors.IntegrityConstraintViolation
	}

	if pgErr.Code.Class().Name() == "data_exception" {
		return dberrors.InvalidInput
	}
	return dberrors.Other
}

Analyzer converts a postgresql-specific error into a generic dberrors.ErrType

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL