gorm icon indicating copy to clipboard operation
gorm copied to clipboard

Custom error

Open eduardo-mior opened this issue 3 years ago • 2 comments

Make sure these boxes checked before submitting your pull request.

  • [x] Do only one thing
  • [x] No API-breaking changes
  • [x] New code/logic commented & tested

For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.

What did this pull request do?

  • Add a field called SQL to the DB stuct. This SQL field contains a String with the last SQL executed.
  • Create a custom error that contains the original error and contains the SQL string that caused the error. With this custom error it is possible which SQL caused the error, this way it is possible to record in sentry and other platforms what happened, it is a better way to know what error is happening.

Looking at my project's error logs, the only thing that comes up is `pq: syntax error at or near") ". I have about 10 ")" in my SQL. How will I know where the error is happening without running SQL? With this new custom error, and with this new SQL property I can know which SQL is causing the problem.

eduardo-mior avatar Jun 21 '21 20:06 eduardo-mior

isn't this repo deprecated?

Gilwe avatar Jun 30 '21 13:06 Gilwe

isn't this repo deprecated?

Yes. This repository is obsolete. But I'm doing maintenance on giant projects that use this repository, and unfortunately I don't have the possibility for GORM V2

eduardo-mior avatar Jun 30 '21 15:06 eduardo-mior