Browse Source

More error messages

default_compile_flags
vector-of-bool 4 years ago
parent
commit
2acc93bf0d
6 changed files with 41 additions and 6 deletions
  1. +4
    -0
      docs/err/invalid-pkg-filesystem.rst
  2. +8
    -0
      docs/err/unknown-test-driver.rst
  3. +12
    -0
      src/dds/error/errors.cpp
  4. +2
    -0
      src/dds/error/errors.hpp
  5. +6
    -1
      src/dds/package/manifest.cpp
  6. +9
    -5
      src/dds/source/dist.cpp

+ 4
- 0
docs/err/invalid-pkg-filesystem.rst View File

@@ -5,6 +5,10 @@ Error: Invalid package filesystem
build and process packages and libraries. This structure isn't overly strict,
and is thoroughly explained on the :doc:`/guide/packages` page.

For exporting/generating a source distribution from a package, the *package
root* requires a ``package.dds`` file and each *library root* requires a
``library.dds`` file.

.. .
TODO: Create are more detailed reference page for package and library layout,
and include those links in a `seealso`.

+ 8
- 0
docs/err/unknown-test-driver.rst View File

@@ -0,0 +1,8 @@
Error: Unknown ``Test-Driver``
##############################

``dds`` has a set of known ``Test-Driver``s built-in, and they may be specified
with the ``Test-Driver`` key. Receiving this error indicates that the specified
``Test-Driver`` was not recognized by ``dds``. Check your spelling, and check
that the driver you want to use is supported by ``dds``. Refer to the
:doc:`/guide/packages` page.

+ 12
- 0
src/dds/error/errors.cpp View File

@@ -46,7 +46,10 @@ std::string error_url_suffix(dds::errc ec) noexcept {
case errc::invalid_config_key:
return "invalid-config-key.html";
case errc::invalid_lib_filesystem:
case errc::invalid_pkg_filesystem:
return "invalid-pkg-filesystem.html";
case errc::unknown_test_driver:
return "unknown-test-driver.html";
case errc::none:
break;
}
@@ -160,10 +163,16 @@ information.
case errc::invalid_config_key:
return R"(The `key' in a `key: value' pair was not recognized.)";
case errc::invalid_lib_filesystem:
case errc::invalid_pkg_filesystem:
return R"(
`dds` prescribes a specific filesystem structure that must be obeyed by
libraries and packages. Refer to the documentation for an explanation and
reference on these prescriptions.
)";
case errc::unknown_test_driver:
return R"(
`dds` has a pre-defined set of built-in test drivers, and the one specified is
not recognized. Check the documentation for more information.
)";
case errc::none:
break;
@@ -214,8 +223,11 @@ std::string_view dds::default_error_string(dds::errc ec) noexcept {
return "Found an invalid configuration key. <- (Seeing this text is a `dds` bug. Please "
"report it.)";
case errc::invalid_lib_filesystem:
case errc::invalid_pkg_filesystem:
return "The filesystem structure of the package/library is invalid. <- (Seeing this text "
"is a `dds` bug. Please report it.)";
case errc::unknown_test_driver:
return "The specified Test-Driver is not known to `dds`";
case errc::none:
break;
}

+ 2
- 0
src/dds/error/errors.hpp View File

@@ -30,8 +30,10 @@ enum class errc {
invalid_version_range_string,
invalid_version_string,
invalid_config_key,
unknown_test_driver,

invalid_lib_filesystem,
invalid_pkg_filesystem,
};

std::string error_reference_of(errc) noexcept;

+ 6
- 1
src/dds/package/manifest.cpp View File

@@ -1,6 +1,7 @@
#include "./manifest.hpp"

#include <dds/dym.hpp>
#include <dds/error/errors.hpp>
#include <dds/util/string.hpp>
#include <libman/parse.hpp>

@@ -41,7 +42,11 @@ package_manifest package_manifest::load_from_file(const fs::path& fpath) {
} else if (test_driver_str == "Catch") {
ret.test_driver = test_lib::catch_;
} else {
throw std::runtime_error(fmt::format("Unknown 'Test-Driver': '{}'", test_driver_str));
auto dym = *did_you_mean(test_driver_str, {"Catch-Main", "Catch"});
throw_user_error<
errc::unknown_test_driver>("Unknown 'Test-Driver' '{}' (Did you mean '{}'?)",
test_driver_str,
dym);
}
}


+ 9
- 5
src/dds/source/dist.cpp View File

@@ -1,5 +1,6 @@
#include "./dist.hpp"

#include <dds/error/errors.hpp>
#include <dds/library/library.hpp>
#include <dds/temp.hpp>
#include <dds/util/fs.hpp>
@@ -44,9 +45,10 @@ void sdist_copy_library(path_ref out_root, const library& lib, const sdist_param

auto lib_dds_path = lib.path() / "library.dds";
if (!fs::is_regular_file(lib_dds_path)) {
throw std::runtime_error(fmt::format(
"Each library in a source distribution requires a library manifest (Expected [{}])",
lib_dds_path.string()));
throw_user_error<errc::invalid_lib_filesystem>(
"Each library root in a source distribution requires a library manifest (Expected "
"[{}])",
lib_dds_path.string());
}
sdist_export_file(out_root, params.project_dir, lib_dds_path);

@@ -88,8 +90,10 @@ sdist dds::create_sdist_in_dir(path_ref out, const sdist_params& params) {

auto man_path = params.project_dir / "package.dds";
if (!fs::is_regular_file(man_path)) {
throw std::runtime_error(fmt::format(
"Creating a source distribution requires a package.dds file for the project"));
throw_user_error<errc::invalid_pkg_filesystem>(
"Creating a source distribution requires a package.dds file for the project (Expected "
"[{}])",
man_path.string());
}
sdist_export_file(out, params.project_dir, man_path);
auto pkg_man = package_manifest::load_from_file(man_path);

Loading…
Cancel
Save