qt_build_utils/error.rs
1// SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
2// SPDX-FileContributor: Andrew Hayzen <andrew.hayzen@kdab.com>
3//
4// SPDX-License-Identifier: MIT OR Apache-2.0
5
6use thiserror::Error;
7
8#[derive(Error, Debug)]
9/// Errors that can occur while using [crate::QtBuild]
10pub enum QtBuildError {
11 /// `QMAKE` environment variable was set but Qt was not detected
12 #[error("QMAKE environment variable specified as {qmake_env_var} but could not detect Qt: {error:?}")]
13 QMakeSetQtMissing {
14 /// The value of the qmake environment variable when the error occurred
15 qmake_env_var: String,
16 /// The inner error that occurred
17 error: Box<anyhow::Error>,
18 },
19 /// Qt was not found
20 #[error("Could not find Qt")]
21 QtMissing,
22 /// Executing `qmake -query` failed
23 #[error("Executing `qmake -query` failed: {0:?}")]
24 QmakeFailed(#[from] std::io::Error),
25 /// `QT_VERSION_MAJOR` environment variable was specified but could not be parsed as an integer
26 #[error("QT_VERSION_MAJOR environment variable specified as {qt_version_major_env_var} but could not parse as integer: {source:?}")]
27 QtVersionMajorInvalid {
28 /// The Qt major version from `QT_VERSION_MAJOR`
29 qt_version_major_env_var: String,
30 /// The [std::num::ParseIntError] when parsing the `QT_VERSION_MAJOR`
31 source: std::num::ParseIntError,
32 },
33 /// `QT_VERSION_MAJOR` environment variable was specified but the Qt version specified by `qmake -query QT_VERSION` did not match
34 #[error("qmake version ({qmake_version}) does not match version specified by QT_VERSION_MAJOR ({qt_version_major})")]
35 QtVersionMajorDoesNotMatch {
36 /// The qmake version
37 qmake_version: u64,
38 /// The Qt major version from `QT_VERSION_MAJOR`
39 qt_version_major: u64,
40 },
41}