Skip to content

C++版本使用FastDeploy和PaddleDetection时,关于异常捕获问题 #2589

Open
@sunshine-app

Description

@sunshine-app

// 创建模型
model = std::make_sharedfastdeploy::vision::detection::PaddleDetectionModel(model_buffer, params_buffer, config_file, option);

问题:
model_buffer和params_buffer是解密后输入的参数,但是这两个值可能会因为密码错误的情况下报错,报错信息:
[Paddle2ONNX] Failed to parse PaddlePaddle model from memory buffer.
[Paddle2ONNX] Failed to load program of PaddlePaddle model from memory.
[ERROR] Failed to parse PaddlePaddle model.

请问这样的异常信息怎么进行捕获呢,避免程序直接异常退出?
catch (const std::exception& e) { // 捕获所有标准异常
init_model_status = 0;
std::cerr << "Standard exception: " << e.what() << std::endl;
}
catch (...) { // 捕获所有其他异常(非标准异常)
init_model_status = 0;
std::cerr << "Unknown exception occurred" << std::endl;
}
两种方式不能捕获到异常信息。设置option.DisablePaddleLogInfo()也无效。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions