Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Oci8Exception object to add access to Oracle debugging detail #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cartbeforehorse
Copy link

As per request for a Pull Request, I'm now submitting changes that I've applied.

The objective is to build better Oracle debugging support into the Oci8Exception class, so that (for example) user-facing error-messages are easier to extract.

These changes are slightly different than the original suggestions documented in the original thread. Rather than allow Exception-throwing code in Statement.php to build a lengthy message string to pass to the Exception object, I've decided to simply pass the PDO exception-array to the Exception class instead, so that the Exception class itself can do the legwork. This reduces the overhead of constructing and de-constructing the message string to find the necessary debug info.

@mstaack
Copy link
Contributor

mstaack commented Jul 10, 2018

@cartbeforehorse really like the idea, could you refomat & cleanup your variables & functions?

@cartbeforehorse
Copy link
Author

@mstaack I'm not clear what I need to do. What is it that needs tidying?

@yajra yajra changed the base branch from 1.0 to master September 5, 2018 03:12
@yajra
Copy link
Owner

yajra commented Sep 5, 2018

Reviewing this and this is the difference when doing a tinker session in Laravel:

With this PR, the console log is:

Psy Shell v0.9.7 (PHP 7.1.19 — cli) by Justin Hileman
>>> factory("App\User")->create()
PHP Warning:  oci_execute(): ORA-01400: cannot insert NULL into ("LARAVEL57"."USERS"."REMARKS") in /www/yajra/oci8/pdo-via-oci8/src/Pdo/Oci8/Statement.php on line 158
Yajra/Pdo/Oci8/Exceptions/Oci8Exception with message 'ORA-01400: cannot insert NULL into ("LARAVEL57"."USERS"."REMARKS")'

This is how it currently looks:

Psy Shell v0.9.7 (PHP 7.1.19 — cli) by Justin Hileman
>>> factory("App\User")->create()
PHP Warning:  oci_execute(): ORA-01400: cannot insert NULL into ("LARAVEL57"."USERS"."REMARKS") in /www/yajra/oci8/pdo-via-oci8/src/Pdo/Oci8/Statement.php on line 158
Yajra/Pdo/Oci8/Exceptions/Oci8Exception with message 'Error Code    : 1400
Error Message : ORA-01400: cannot insert NULL into ("LARAVEL57"."USERS"."REMARKS")
Position      : 0
Statement     : insert into "USERS" ("NAME", "EMAIL", "PASSWORD", "REMEMBER_TOKEN", "UPDATED_AT", "CREATED_AT") values (:p0, :p1, :p2, :p3, :p4, :p5) returning "ID" into :p6
Bindings      : [Prof. Zita Ryan Sr.,[email protected],$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm,JUanCgKavf,2018-09-05 03:15:34,2018-09-05 03:15:34,0]
'

In this regard, I guess we could retain the original error display but we can add a chain of error that the user can use to fit their requirements. What do you think? Thanks!

@@ -166,15 +166,8 @@ public function execute($inputParams = null)

if ($result != true) {
$e = oci_error($this->sth);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can retain this message part as it is easier to debug with all this error message displayed by default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants