Blame view

node_modules/sshpk/lib/errors.js 2.71 KB
aaac7fed   liuqimichale   add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
  // Copyright 2015 Joyent, Inc.
  
  var assert = require('assert-plus');
  var util = require('util');
  
  function FingerprintFormatError(fp, format) {
  	if (Error.captureStackTrace)
  		Error.captureStackTrace(this, FingerprintFormatError);
  	this.name = 'FingerprintFormatError';
  	this.fingerprint = fp;
  	this.format = format;
  	this.message = 'Fingerprint format is not supported, or is invalid: ';
  	if (fp !== undefined)
  		this.message += ' fingerprint = ' + fp;
  	if (format !== undefined)
  		this.message += ' format = ' + format;
  }
  util.inherits(FingerprintFormatError, Error);
  
  function InvalidAlgorithmError(alg) {
  	if (Error.captureStackTrace)
  		Error.captureStackTrace(this, InvalidAlgorithmError);
  	this.name = 'InvalidAlgorithmError';
  	this.algorithm = alg;
  	this.message = 'Algorithm "' + alg + '" is not supported';
  }
  util.inherits(InvalidAlgorithmError, Error);
  
  function KeyParseError(name, format, innerErr) {
  	if (Error.captureStackTrace)
  		Error.captureStackTrace(this, KeyParseError);
  	this.name = 'KeyParseError';
  	this.format = format;
  	this.keyName = name;
  	this.innerErr = innerErr;
  	this.message = 'Failed to parse ' + name + ' as a valid ' + format +
  	    ' format key: ' + innerErr.message;
  }
  util.inherits(KeyParseError, Error);
  
  function SignatureParseError(type, format, innerErr) {
  	if (Error.captureStackTrace)
  		Error.captureStackTrace(this, SignatureParseError);
  	this.name = 'SignatureParseError';
  	this.type = type;
  	this.format = format;
  	this.innerErr = innerErr;
  	this.message = 'Failed to parse the given data as a ' + type +
  	    ' signature in ' + format + ' format: ' + innerErr.message;
  }
  util.inherits(SignatureParseError, Error);
  
  function CertificateParseError(name, format, innerErr) {
  	if (Error.captureStackTrace)
  		Error.captureStackTrace(this, CertificateParseError);
  	this.name = 'CertificateParseError';
  	this.format = format;
  	this.certName = name;
  	this.innerErr = innerErr;
  	this.message = 'Failed to parse ' + name + ' as a valid ' + format +
  	    ' format certificate: ' + innerErr.message;
  }
  util.inherits(CertificateParseError, Error);
  
  function KeyEncryptedError(name, format) {
  	if (Error.captureStackTrace)
  		Error.captureStackTrace(this, KeyEncryptedError);
  	this.name = 'KeyEncryptedError';
  	this.format = format;
  	this.keyName = name;
  	this.message = 'The ' + format + ' format key ' + name + ' is ' +
  	    'encrypted (password-protected), and no passphrase was ' +
  	    'provided in `options`';
  }
  util.inherits(KeyEncryptedError, Error);
  
  module.exports = {
  	FingerprintFormatError: FingerprintFormatError,
  	InvalidAlgorithmError: InvalidAlgorithmError,
  	KeyParseError: KeyParseError,
  	SignatureParseError: SignatureParseError,
  	KeyEncryptedError: KeyEncryptedError,
  	CertificateParseError: CertificateParseError
  };