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

Cannot read properties of undefined (reading 'QueryResultError') #947

Open
psm-solution-group opened this issue Dec 4, 2024 · 0 comments
Assignees
Labels
triage To be investigated

Comments

@psm-solution-group
Copy link

Expected behavior

I want to display my error message but I got this error:

TypeError: Cannot read properties of undefined (reading 'QueryResultError')

Actual behavior

I know my error on my code but I want to test my display error code, so it throw an error on errors.QueryResultError. Why ?

Steps to reproduce

  try {
    const clientById: TGetClientOneData[] = await pg.query(`
      SELECT
      
      c.id,
      c.company,
      c.paid,
      c.created_at,

      (SELECT COUNT(id) as total FROM users WHERE company_id = $1) as total

      FROM clients

      WHERE c.id = $1 AND c.tenant_id = $2 LIMIT 1;
    `, [id, tenant_id]);

    return clientById[0];
  } catch(e) {
  if(e instanceof errors.QueryResultError) {
    throw new ErrorException(e.code, e.message);
  }
  }

Environment

Nodejs v20

  • Version of pg-promise:
  • OS type (Linux/Windows/Mac):
  • Version of Node.js:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage To be investigated
Projects
None yet
Development

No branches or pull requests

2 participants