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

Error object returned from connect where mapped tables do not exist needs more information #25

Open
jdduncan opened this issue Sep 24, 2015 · 4 comments

Comments

@jdduncan
Copy link
Contributor

openSession() and connect() can be used to validate mappings.

  1. If the mappings are not valid, the error returned by connect() is strange. For instance, if five mappings were to be validated, and all five received errors, the error object seems to be an array of five elements, but the prototype of the array is Error. I tried using a variety of console.log(), util.inspect(), etc. to view the five members of this structure but I was not able to.

  2. The docs in API-documentation/Jones are not clear about whether a failure to validate the mappings causes openSession() or connect() to fail.

One way to reproduce this:
cd samples/tweet

neglect to create the tables used by tweet.js

node tweet.js get tweets-at nero

@CraigLRussell
Copy link
Contributor

On Sep 24, 2015, at 2:36 PM, John David Duncan [email protected] wrote:

openSession() and connect() can be used to validate mappings.

  1. If the mappings are not valid, the error returned by connect() is strange. For instance, if five mappings were to be validated, and all five received errors, the error object seems to be an array of five elements, but the prototype of the array is Error. I tried using a variety of console.log(), util.inspect(), etc. to view the five members of this structure but I was not able to.

Fixed this. The error object should have been turned into a string via util.inspect before being appended to the Error. Now, the result is:

clr% node tweet.js get tweets-at nero
Connected to cluster as node id: 5
[Error:
Error resolving table tweet for domain object Tweet: { message: 'No such table existed',
handler_error_code: 155,
code: 723,
classification: 'SchemaError',
status: 'PermanentError',
sqlState: '42S02' }
Error resolving table author for domain object Author: { message: 'No such table existed',
handler_error_code: 155,
code: 723,
classification: 'SchemaError',
status: 'PermanentError',
sqlState: '42S02' }
Error resolving table hashtag for domain object HashtagEntry: { message: 'No such table existed',
handler_error_code: 155,
code: 723,
classification: 'SchemaError',
status: 'PermanentError',
sqlState: '42S02' }
Error resolving table follow for domain object Follow: { message: 'No such table existed',
handler_error_code: 155,
code: 723,
classification: 'SchemaError',
status: 'PermanentError',
sqlState: '42S02' }
Error resolving table mention for domain object Mention: { message: 'No such table existed',
handler_error_code: 155,
code: 723,
classification: 'SchemaError',
status: 'PermanentError',
sqlState: '42S02' }]

  1. The docs in API-documentation/Jones are not clear about whether a failure to validate the mappings causes openSession() or connect() to fail.

Yes, openSession or connect should (and does) fail. We have test cases for failures of mappings, which I saw when I debugged your case.

Craig

One way to reproduce this:
cd samples/tweet

neglect to create the tables used by tweet.js

node tweet.js get tweets-at nero


Reply to this email directly or view it on GitHub #25.

Craig L RussellArchitect, Oraclehttp://db.apache.org/jdo408 276-5638 mailto:[email protected]. A good JDO? O, Gasp!

@jdduncan
Copy link
Contributor Author

Now the error message is much better if the tables are not found, but there is still one problem. If you fail to connect because you really can't connect to the server, you get error 08000 "Connection Failed". However, if you can't connect to the server and you tried to validate 5 mappings, you get the five 42S02 "No such table existed" errors but not the 08000 error. Since the 08000 "Connection Failed" is the root cause it seems that this should be the error the user sees. Reopening issue.

@jdduncan jdduncan reopened this Sep 28, 2015
@CraigLRussell
Copy link
Contributor

Let’s discuss.

UserContext.getSessionFactory mapping errors [Error:
Error resolving table tbl8: { [Error: ER_NO_SUCH_TABLE: Table 'test.tbl8' doesn't exist]
code: 'ER_NO_SUCH_TABLE',
errno: 1146,
sqlState: '42S02',
index: 0 }]
UserContext.getSessionFactory mapping errors [Error:
Error resolving table mysqljs_multidb_test.tbl8: { [Error: ER_NO_SUCH_TABLE: Table 'mysqljs_multidb_test.tbl8' doesn't exist]
code: 'ER_NO_SUCH_TABLE',
errno: 1146,
sqlState: '42S02',
index: 0 }]
UserContext.getSessionFactory mapping errors [Error:
Error resolving table tbl8 for domain object : { [Error: ER_NO_SUCH_TABLE: Table 'test.tbl8' doesn't exist]
code: 'ER_NO_SUCH_TABLE',
errno: 1146,
sqlState: '42S02',
index: 0 }]
[pass] multidb ConnectTest.js testOpenSessionExplicitTable
UserContext.getSessionFactory mapping errors [Error:
Error resolving table tbl8 for domain object : { [Error: ER_NO_SUCH_TABLE: Table 'mysqljs_multidb_test.tbl8' doesn't exist]
code: 'ER_NO_SUCH_TABLE',
errno: 1146,
sqlState: '42S02',
index: 0 }]
UserContext.getSessionFactory mapping errors [Error:
Error resolving table function (i, j) {
this.i = i;
this.j = j;
}: [Error: User exception: constructor for must have been annotated (call TableMapping.applyToClass).]]
[pass] multidb ConnectTest.js testFailureCases

On Sep 28, 2015, at 3:19 PM, John David Duncan [email protected] wrote:

Now the error message is much better if the tables are not found, but there is still one problem. If you fail to connect because you really can't connect to the server, you get error 08000 "Connection Failed". However, if you can't connect to the server and you tried to validate 5 mappings, you get the five 42S02 "No such table existed" errors but not the 08000 error. Since the 08000 "Connection Failed" is the root cause it seems that this should be the error the user sees. Reopening issue.


Reply to this email directly or view it on GitHub #25 (comment).

Craig L RussellArchitect, Oraclehttp://db.apache.org/jdo408 276-5638 mailto:[email protected]. A good JDO? O, Gasp!

@CraigLRussell CraigLRussell changed the title Strange error return from connect() Error object returned from connect where mapped tables do not exist needs more informaiton Sep 29, 2015
@CraigLRussell CraigLRussell changed the title Error object returned from connect where mapped tables do not exist needs more informaiton Error object returned from connect where mapped tables do not exist needs more information Sep 29, 2015
@CraigLRussell
Copy link
Contributor

The error object should also include the code, errno, and sqlState of the first failed mapping.

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

No branches or pull requests

2 participants