Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

异常类

class X509Exception

public class X509Exception <: Exception {
    public init()
    public init(message: String)
}

功能:此异常为 X509 包抛出的异常类型。

父类型:

  • Exception

init()

public init()

功能:构造 X509Exception 对象。

示例:

import stdx.crypto.x509.*

main() {
    try {
        // 抛出一个无参的X509Exception异常
        throw X509Exception()
    } catch (e: X509Exception) {
        println("捕获到X509异常: ${e}")
    }
}

运行结果:

捕获到X509异常: X509Exception

init(String)

public init(message: String)

功能:构造 X509Exception 对象。

参数:

  • message: String - 异常的信息。

示例:

import stdx.crypto.x509.*

main() {
    try {
        // 抛出一个带消息的X509Exception异常
        throw X509Exception("证书验证失败")
    } catch (e: X509Exception) {
        println("捕获到X509异常: ${e}")
    }
}

运行结果:

捕获到X509异常: X509Exception: 证书验证失败