Skip to content

Commit 328cc00

Browse files
committed
qt-build-utils: split error into separate module
1 parent cdaf205 commit 328cc00

File tree

2 files changed

+44
-36
lines changed

2 files changed

+44
-36
lines changed

crates/qt-build-utils/src/error.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
2+
// SPDX-FileContributor: Andrew Hayzen <[email protected]>
3+
//
4+
// SPDX-License-Identifier: MIT OR Apache-2.0
5+
6+
use thiserror::Error;
7+
8+
#[derive(Error, Debug)]
9+
/// Errors that can occur while using [QtBuild]
10+
pub 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+
}

crates/qt-build-utils/src/lib.rs

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
1616
#![allow(clippy::too_many_arguments)]
1717

18+
mod error;
19+
pub use error::QtBuildError;
20+
1821
mod installation;
1922
pub use installation::QtInstallation;
2023

@@ -38,42 +41,6 @@ use std::{
3841
};
3942

4043
use semver::Version;
41-
use thiserror::Error;
42-
43-
#[derive(Error, Debug)]
44-
/// Errors that can occur while using [QtBuild]
45-
pub enum QtBuildError {
46-
/// `QMAKE` environment variable was set but Qt was not detected
47-
#[error("QMAKE environment variable specified as {qmake_env_var} but could not detect Qt: {error:?}")]
48-
QMakeSetQtMissing {
49-
/// The value of the qmake environment variable when the error occurred
50-
qmake_env_var: String,
51-
/// The inner error that occurred
52-
error: Box<anyhow::Error>,
53-
},
54-
/// Qt was not found
55-
#[error("Could not find Qt")]
56-
QtMissing,
57-
/// Executing `qmake -query` failed
58-
#[error("Executing `qmake -query` failed: {0:?}")]
59-
QmakeFailed(#[from] std::io::Error),
60-
/// `QT_VERSION_MAJOR` environment variable was specified but could not be parsed as an integer
61-
#[error("QT_VERSION_MAJOR environment variable specified as {qt_version_major_env_var} but could not parse as integer: {source:?}")]
62-
QtVersionMajorInvalid {
63-
/// The Qt major version from `QT_VERSION_MAJOR`
64-
qt_version_major_env_var: String,
65-
/// The [std::num::ParseIntError] when parsing the `QT_VERSION_MAJOR`
66-
source: std::num::ParseIntError,
67-
},
68-
/// `QT_VERSION_MAJOR` environment variable was specified but the Qt version specified by `qmake -query QT_VERSION` did not match
69-
#[error("qmake version ({qmake_version}) does not match version specified by QT_VERSION_MAJOR ({qt_version_major})")]
70-
QtVersionMajorDoesNotMatch {
71-
/// The qmake version
72-
qmake_version: u64,
73-
/// The Qt major version from `QT_VERSION_MAJOR`
74-
qt_version_major: u64,
75-
},
76-
}
7744

7845
fn command_help_output(command: &str) -> std::io::Result<std::process::Output> {
7946
Command::new(command).args(["--help"]).output()

0 commit comments

Comments
 (0)