Skip to content

Commit 5980b8c

Browse files
committed
Introduce base SyncError
1 parent 2dba52d commit 5980b8c

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lib/errors/sync-error.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
class SyncError extends Error {
4+
constructor(message) {
5+
super(message);
6+
this.createdAt = Date.now();
7+
this.name = this.constructor.name;
8+
Error.captureStackTrace(this, this.constructor);
9+
}
10+
}
11+
12+
module.exports = SyncError;

lib/errors/validation/validation-error.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
'use strict';
22

3-
class ValidationError extends Error {
3+
const SyncError = require('../sync-error');
4+
5+
class ValidationError extends SyncError {
46
constructor(instance, message = '') {
57
const modelName = instance.constructor.name;
6-
const id = instance.id;
7-
super(getMessage(message, modelName, id));
8-
Object.assign(this, { instance, id, modelName });
9-
Error.captureStackTrace(this, this.constructor);
8+
const instanceId = instance.id;
9+
super(getMessage(message, modelName, instanceId));
10+
Object.assign(this, { instance, instanceId, modelName });
1011
}
1112
}
1213

0 commit comments

Comments
 (0)