1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | class LockfileError extends Error {
|
4 | constructor({ msg, file, reason }) {
|
5 | super(msg || (reason ? `${reason}: ${file}` : `lock exists!: ${file}`));
|
6 | this.code = 'ELOCK';
|
7 | this.file = file;
|
8 | this.msg = msg;
|
9 | this.reason = reason;
|
10 | }
|
11 | }
|
12 | exports.LockfileError = LockfileError;
|
13 | class RWLockfileError extends LockfileError {
|
14 | constructor(status) {
|
15 | switch (status.status) {
|
16 | case 'write_lock':
|
17 | super({ file: status.file, msg: `write lock exists: ${status.job.reason || ''}` });
|
18 | break;
|
19 | case 'read_lock':
|
20 | super({ file: status.file, msg: `read lock exists: ${status.jobs[0].reason || ''}` });
|
21 | break;
|
22 | default:
|
23 | throw new Error(`Unexpected status: ${status.status}`);
|
24 | }
|
25 | this.status = status;
|
26 | }
|
27 | }
|
28 | exports.RWLockfileError = RWLockfileError;
|