1 // Copyright 2015 Joyent, Inc.
3 var assert = require('assert-plus');
4 var util = require('util');
6 function FingerprintFormatError(fp, format) {
7 if (Error.captureStackTrace)
8 Error.captureStackTrace(this, FingerprintFormatError);
9 this.name = 'FingerprintFormatError';
10 this.fingerprint = fp;
12 this.message = 'Fingerprint format is not supported, or is invalid: ';
14 this.message += ' fingerprint = ' + fp;
15 if (format !== undefined)
16 this.message += ' format = ' + format;
18 util.inherits(FingerprintFormatError, Error);
20 function InvalidAlgorithmError(alg) {
21 if (Error.captureStackTrace)
22 Error.captureStackTrace(this, InvalidAlgorithmError);
23 this.name = 'InvalidAlgorithmError';
25 this.message = 'Algorithm "' + alg + '" is not supported';
27 util.inherits(InvalidAlgorithmError, Error);
29 function KeyParseError(name, format, innerErr) {
30 if (Error.captureStackTrace)
31 Error.captureStackTrace(this, KeyParseError);
32 this.name = 'KeyParseError';
35 this.innerErr = innerErr;
36 this.message = 'Failed to parse ' + name + ' as a valid ' + format +
37 ' format key: ' + innerErr.message;
39 util.inherits(KeyParseError, Error);
41 function SignatureParseError(type, format, innerErr) {
42 if (Error.captureStackTrace)
43 Error.captureStackTrace(this, SignatureParseError);
44 this.name = 'SignatureParseError';
47 this.innerErr = innerErr;
48 this.message = 'Failed to parse the given data as a ' + type +
49 ' signature in ' + format + ' format: ' + innerErr.message;
51 util.inherits(SignatureParseError, Error);
53 function CertificateParseError(name, format, innerErr) {
54 if (Error.captureStackTrace)
55 Error.captureStackTrace(this, CertificateParseError);
56 this.name = 'CertificateParseError';
59 this.innerErr = innerErr;
60 this.message = 'Failed to parse ' + name + ' as a valid ' + format +
61 ' format certificate: ' + innerErr.message;
63 util.inherits(CertificateParseError, Error);
65 function KeyEncryptedError(name, format) {
66 if (Error.captureStackTrace)
67 Error.captureStackTrace(this, KeyEncryptedError);
68 this.name = 'KeyEncryptedError';
71 this.message = 'The ' + format + ' format key ' + name + ' is ' +
72 'encrypted (password-protected), and no passphrase was ' +
73 'provided in `options`';
75 util.inherits(KeyEncryptedError, Error);
78 FingerprintFormatError: FingerprintFormatError,
79 InvalidAlgorithmError: InvalidAlgorithmError,
80 KeyParseError: KeyParseError,
81 SignatureParseError: SignatureParseError,
82 KeyEncryptedError: KeyEncryptedError,
83 CertificateParseError: CertificateParseError