28 lines
1.0 KiB
Plaintext
28 lines
1.0 KiB
Plaintext
import { CryptoBridgeErrorCode, CryptoBridgeFailure } from "./interface.uts"
|
|
|
|
export const CryptoErrorSubject = "laoqianjunzi-crypto"
|
|
|
|
export const CryptoErrorMessages : Map<CryptoBridgeErrorCode, string> = new Map([
|
|
[7401, "crypto bridge: text input is empty"],
|
|
[7402, "crypto bridge: unsupported codec kind"],
|
|
[7403, "crypto bridge: unsupported digest kind"],
|
|
[7404, "crypto bridge: unsupported hmac kind"],
|
|
[7405, "crypto bridge: unsupported block mode"],
|
|
[7406, "crypto bridge: unsupported padding kind"],
|
|
[7407, "crypto bridge: invalid cipher payload"],
|
|
[7408, "crypto bridge: invalid key or iv"],
|
|
[7409, "crypto bridge: rsa operation failed"],
|
|
[7410, "crypto bridge: current platform is missing required capability"]
|
|
])
|
|
|
|
export class CryptoBridgeFailureImpl extends UniError implements CryptoBridgeFailure {
|
|
override errCode : CryptoBridgeErrorCode
|
|
|
|
constructor(errCode : CryptoBridgeErrorCode) {
|
|
super()
|
|
this.errSubject = CryptoErrorSubject
|
|
this.errCode = errCode
|
|
this.errMsg = CryptoErrorMessages[errCode] ?? ""
|
|
}
|
|
}
|