Skip to content

Commit 4ff9e88

Browse files
committed
define Insert in crypto_util.h itself
1 parent b995a71 commit 4ff9e88

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/crypto/crypto_util.cc

-27
Original file line numberDiff line numberDiff line change
@@ -201,33 +201,6 @@ bool CryptoErrorStore::Empty() const {
201201
return errors_.empty();
202202
}
203203

204-
template<typename... Args>
205-
void CryptoErrorStore::Insert(const NodeCryptoError error, Args&&... args) {
206-
const char* error_string;
207-
switch (error) {
208-
case NodeCryptoError::CIPHER_JOB_FAILED:
209-
error_string = "Cipher job failed";
210-
break;
211-
case NodeCryptoError::DERIVING_BITS_FAILED:
212-
error_string = "Deriving bits failed";
213-
break;
214-
case NodeCryptoError::ENGINE_NOT_FOUND:
215-
error_string = "Engine \"%s\" was not found";
216-
break;
217-
case NodeCryptoError::INVALID_KEY_TYPE:
218-
error_string = "Invalid key type";
219-
break;
220-
case NodeCryptoError::KEY_GENERATION_JOB_FAILED:
221-
error_string = "Key generation failed";
222-
break;
223-
case NodeCryptoError::NO_ERROR:
224-
error_string = "No error";
225-
break;
226-
}
227-
errors.emplace_back(SPrintF(error_string,
228-
std::forward<Args>(args)...));
229-
}
230-
231204
MaybeLocal<Value> CryptoErrorStore::ToException(
232205
Environment* env,
233206
Local<String> exception_string) const {

src/crypto/crypto_util.h

+27
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,33 @@ struct CryptoErrorStore {
186186
std::vector<std::string> errors_;
187187
};
188188

189+
template <typename... Args>
190+
void CryptoErrorStore::Insert(const NodeCryptoError error, Args&&... args) {
191+
const char* error_string;
192+
switch (error) {
193+
case NodeCryptoError::CIPHER_JOB_FAILED:
194+
error_string = "Cipher job failed";
195+
break;
196+
case NodeCryptoError::DERIVING_BITS_FAILED:
197+
error_string = "Deriving bits failed";
198+
break;
199+
case NodeCryptoError::ENGINE_NOT_FOUND:
200+
error_string = "Engine \"%s\" was not found";
201+
break;
202+
case NodeCryptoError::INVALID_KEY_TYPE:
203+
error_string = "Invalid key type";
204+
break;
205+
case NodeCryptoError::KEY_GENERATION_JOB_FAILED:
206+
error_string = "Key generation failed";
207+
break;
208+
case NodeCryptoError::NO_ERROR:
209+
error_string = "No error";
210+
break;
211+
}
212+
errors_.emplace_back(SPrintF(error_string,
213+
std::forward<Args>(args)...));
214+
}
215+
189216
template <typename T>
190217
T* MallocOpenSSL(size_t count) {
191218
void* mem = OPENSSL_malloc(MultiplyWithOverflowCheck(count, sizeof(T)));

0 commit comments

Comments
 (0)