@@ -2131,6 +2131,56 @@ defmodule UnicodeConversionError do
2131
2131
end
2132
2132
end
2133
2133
2134
+ defmodule MissingApplicationsError do
2135
+ @ moduledoc """
2136
+ An exception that is raised when an application depends on one or more
2137
+ missing applications.
2138
+
2139
+ This exception is used by Mix and other tools. It can also be used by library authors
2140
+ when their library only requires an external application (like a dependency) for a subset
2141
+ of features.
2142
+
2143
+ The fields of this exception are public. See `t:t/0`.
2144
+
2145
+ *Available since v1.18.0.*
2146
+
2147
+ ## Examples
2148
+
2149
+ unless Application.spec(:plug, :vsn) do
2150
+ raise MissingApplicationsError,
2151
+ description: "application :plug is required for testing Plug-related functionality",
2152
+ apps: [{:plug, "~> 1.0"}]
2153
+ end
2154
+
2155
+ """
2156
+
2157
+ @ moduledoc since: "1.18.0"
2158
+
2159
+ @ type t ( ) :: % __MODULE__ {
2160
+ apps: [ { Application . app ( ) , Version . requirement ( ) } , ... ] ,
2161
+ description: String . t ( )
2162
+ }
2163
+
2164
+ defexception apps: [ ] , description: "missing applications found"
2165
+
2166
+ @ impl true
2167
+ def message ( % __MODULE__ { apps: apps , description: description } ) do
2168
+ # We explicitly format these as tuples so that they're easier to copy-paste
2169
+ # into dependencies.
2170
+ formatted_apps =
2171
+ Enum . map ( apps , fn { app_name , requirement } ->
2172
+ ~s( \n {#{ inspect ( app_name ) } , "#{ requirement } "})
2173
+ end )
2174
+
2175
+ """
2176
+ #{ description }
2177
+
2178
+ To address this, include these applications as your dependencies:
2179
+ #{ formatted_apps } \
2180
+ """
2181
+ end
2182
+ end
2183
+
2134
2184
defmodule Enum.OutOfBoundsError do
2135
2185
@ moduledoc """
2136
2186
An exception that is raised when a function expects an enumerable to have
0 commit comments