Browse Source

Error page for package layout issues

default_compile_flags
vector-of-bool 4 years ago
parent
commit
13a297ac32
4 changed files with 28 additions and 2 deletions
  1. +10
    -0
      docs/err/invalid-pkg-filesystem.rst
  2. +11
    -0
      src/dds/error/errors.cpp
  3. +2
    -0
      src/dds/error/errors.hpp
  4. +5
    -2
      src/dds/library/library.cpp

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

@@ -0,0 +1,10 @@
Error: Invalid package filesystem
#################################

``dds`` prescribes a filesystem structure that must be followed for it to
build and process packages and libraries. This structure isn't overly strict,
and is thoroughly explained on the :doc:`/guide/packages` page.

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

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

@@ -45,6 +45,8 @@ std::string error_url_suffix(dds::errc ec) noexcept {
return "invalid-version-string.html";
case errc::invalid_config_key:
return "invalid-config-key.html";
case errc::invalid_lib_filesystem:
return "invalid-pkg-filesystem.html";
case errc::none:
break;
}
@@ -157,6 +159,12 @@ information.
)";
case errc::invalid_config_key:
return R"(The `key' in a `key: value' pair was not recognized.)";
case errc::invalid_lib_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::none:
break;
}
@@ -205,6 +213,9 @@ std::string_view dds::default_error_string(dds::errc ec) noexcept {
case errc::invalid_config_key:
return "Found an invalid configuration key. <- (Seeing this text is a `dds` bug. Please "
"report it.)";
case errc::invalid_lib_filesystem:
return "The filesystem structure of the package/library is invalid. <- (Seeing this text "
"is a `dds` bug. Please report it.)";
case errc::none:
break;
}

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

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

invalid_lib_filesystem,
};

std::string error_reference_of(errc) noexcept;

+ 5
- 2
src/dds/library/library.cpp View File

@@ -1,6 +1,7 @@
#include <dds/library/library.hpp>

#include <dds/build/plan/compile_file.hpp>
#include <dds/error/errors.hpp>
#include <dds/source/dir.hpp>
#include <dds/util/algo.hpp>

@@ -20,7 +21,8 @@ auto collect_pf_sources(path_ref path) {

if (include_dir.exists()) {
if (!fs::is_directory(include_dir.path)) {
throw std::runtime_error("The `include` at the root of the project is not a directory");
throw_user_error<errc::invalid_lib_filesystem>(
"The `include` at the library root [in {}] is a non-directory file", path.string());
}
auto inc_sources = include_dir.collect_sources();
// Drop any source files we found within `include/`
@@ -37,7 +39,8 @@ auto collect_pf_sources(path_ref path) {

if (src_dir.exists()) {
if (!fs::is_directory(src_dir.path)) {
throw std::runtime_error("The `src` at the root of the project is not a directory");
throw_user_error<errc::invalid_lib_filesystem>(
"The `src` at the library root [in {}] is a non-directory file", path.string());
}
auto src_sources = src_dir.collect_sources();
extend(sources, src_sources);

Loading…
Cancel
Save