Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 9a8f607

Browse files
committed
Resolve issue #336
1 parent b62e303 commit 9a8f607

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

docs/examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ with ldapjs.
289289
var entry = req.toObject().attributes;
290290

291291
if (entry.objectclass.indexOf('unixUser') === -1)
292-
return next(new ldap.ConstraintViolation('entry must be a unixUser'));
292+
return next(new ldap.ConstraintViolationError('entry must be a unixUser'));
293293

294294
var opts = ['-m'];
295295
if (entry.description) {

docs/guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ the following code in as another handler (you'll need a
409409
var entry = req.toObject().attributes;
410410

411411
if (entry.objectclass.indexOf('unixUser') === -1)
412-
return next(new ldap.ConstraintViolation('entry must be a unixUser'));
412+
return next(new ldap.ConstraintViolationError('entry must be a unixUser'));
413413

414414
var opts = ['-m'];
415415
if (entry.description) {
@@ -496,7 +496,7 @@ As before, here's a breakdown of the code:
496496
var entry = req.toObject().attributes;
497497

498498
if (entry.objectclass.indexOf('unixUser') === -1)
499-
return next(new ldap.ConstraintViolation('entry must be a unixUser'));
499+
return next(new ldap.ConstraintViolationError('entry must be a unixUser'));
500500

501501
A few new things:
502502

test/errors.test.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
'use strict'
22

33
const { test } = require('tap')
4-
const { LDAPError, ConnectionError, AbandonedError, TimeoutError, LDAP_OTHER } = require('../lib')
4+
const {
5+
LDAPError,
6+
ConnectionError,
7+
AbandonedError,
8+
TimeoutError,
9+
ConstraintViolationError,
10+
LDAP_OTHER
11+
} = require('../lib')
512

613
test('basic error', function (t) {
714
const msg = 'mymsg'
@@ -14,6 +21,17 @@ test('basic error', function (t) {
1421
t.end()
1522
})
1623

24+
test('exports ConstraintViolationError', function (t) {
25+
const msg = 'mymsg'
26+
const err = new ConstraintViolationError(msg, null, null)
27+
t.ok(err)
28+
t.equal(err.name, 'ConstraintViolationError')
29+
t.equal(err.code, 19)
30+
t.equal(err.dn, '')
31+
t.equal(err.message, msg)
32+
t.end()
33+
})
34+
1735
test('"custom" errors', function (t) {
1836
const errors = [
1937
{ name: 'ConnectionError', Func: ConnectionError },

0 commit comments

Comments
 (0)