diff --git a/src/rebar3_hex_build.erl b/src/rebar3_hex_build.erl index d901507e..92418569 100644 --- a/src/rebar3_hex_build.erl +++ b/src/rebar3_hex_build.erl @@ -63,21 +63,24 @@ create_package(State, #{name := RepoName} = _Repo, App) -> | OptionalFiltered ]), - Tarball = create_package_tarball(Metadata, PackageFiles), - - Package = #{ - name => PkgName, - repo_name => RepoName, - deps => Deps1, - version => Version, - metadata => Metadata, - files => PackageFiles, - tarball => Tarball, - has_checkouts => has_checkouts(State) - }, - {ok, Package}; - {error, _} = Err -> - Err + case create_package_tarball(Metadata, PackageFiles) of + {error, _} = Err -> + Err; + Tarball -> + Package = #{ + name => PkgName, + repo_name => RepoName, + deps => Deps1, + version => Version, + metadata => Metadata, + files => PackageFiles, + tarball => Tarball, + has_checkouts => has_checkouts(State) + }, + {ok, Package} + end; + Error -> + Error end. update_versions(ConfigDeps, LockDeps) -> @@ -178,8 +181,8 @@ create_docs(State, Repo, App, Args) -> {ok, #{ tarball => Tarball, name => binarify(PkgName), vsn => binarify(Vsn) }}; - {error, _} = Err -> - Err; + {error, Reason} -> + {error, hex_tarball:format_error(Reason)}; Err -> Err end; @@ -268,8 +271,8 @@ create_package_tarball(Metadata, Files) -> case hex_tarball:create(Metadata, Files) of {ok, #{tarball := Tarball, inner_checksum := _Checksum}} -> Tarball; - {error, _} = Err -> - Err; + {error, Reason} -> + {error, hex_tarball:format_error(Reason)}; Error -> Error end. diff --git a/src/rebar3_hex_publish.erl b/src/rebar3_hex_publish.erl index ba247464..6c965485 100644 --- a/src/rebar3_hex_publish.erl +++ b/src/rebar3_hex_publish.erl @@ -97,6 +97,8 @@ format_error({app_not_found, AppName}) -> io_lib:format("App ~s specified with --app switch not found in project", [AppName]); format_error(bad_command) -> "bad command"; +format_error({create_package, {error, Err}}) when is_list(Err) -> + io_lib:format("Error creating package : ~ts", [Err]); format_error({publish_package, app_switch_required}) -> "--app required when publishing with the package argument in a umbrella"; format_error({publish_docs, app_switch_required}) -> @@ -119,6 +121,13 @@ format_error({publish, {error, #{<<"message">> := Message}}}) -> io_lib:format("Failed to publish package: ~ts", [Message]); format_error({create_docs, {error, {doc_provider_not_found, PrvName}}}) -> io_lib:format("The ~ts documentation provider could not be found", [PrvName]); +format_error({create_docs, {error, {doc_provider_failed, PrvName}}}) -> + io_lib:format("The ~ts documentation provider failed", [PrvName]); +format_error({create_docs, {error, missing_doc_index}}) -> + "No index.html file was found in expected docs directory.\n" + "If you provided --doc-dir option ensure that your docs were generated before running this task.\n" + "Otherwise, check that your preferred doc provider is properly generating docs outside the scope of this task.\n" + "Once resolved, run rebar3 hex publish docs to publish only the docs for this version of your package.\n"; format_error({non_hex_deps, Excluded}) -> Err = "Can not publish package because the following deps are not available" ++ " in hex: ~s", @@ -369,6 +378,8 @@ create_docs(State, Repo, App, Args) -> case rebar3_hex_build:create_docs(State, Repo, App, Args) of {ok, Docs} -> Docs; + {error, no_doc_config} -> + rebar_api:warn("No documentation provider was configured, docs will not be generated.", []); Err -> ?RAISE({create_docs, Err}) end.