Skip to content

Commit

Permalink
Deprecate default load and loadOrThrow
Browse files Browse the repository at this point in the history
  • Loading branch information
ruippeixotog committed Aug 27, 2019
1 parent 873c8f3 commit 0fac76a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ As a result we recommend only using the latest Scala versions within the minor s
In your code, import `pureconfig.generic.auto` and define data types and a case class to hold the configuration:

```scala
import pureconfig._
import pureconfig.generic.auto._

sealed trait MyAdt
Expand All @@ -66,7 +67,7 @@ resource file of your application (with SBT, they are usually placed in `src/mai
Finally, load the configuration:

```scala
pureconfig.loadConfig[MyClass]
ConfigSource.default.load[MyClass]
// res0: pureconfig.ConfigReader.Result[MyClass] = Right(MyClass(true,Port(8080),AdtB(1),List(1.0, 0.2),Map(key -> value),None))
```

Expand Down
3 changes: 2 additions & 1 deletion bundle/src/main/tut/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ As a result we recommend only using the latest Scala versions within the minor s
In your code, import `pureconfig.generic.auto` and define data types and a case class to hold the configuration:

```scala
import pureconfig._
import pureconfig.generic.auto._

sealed trait MyAdt
Expand All @@ -66,7 +67,7 @@ resource file of your application (with SBT, they are usually placed in `src/mai
Finally, load the configuration:

```scala
pureconfig.loadConfig[MyClass]
ConfigSource.default.load[MyClass]
// res0: pureconfig.ConfigReader.Result[MyClass] = Right(MyClass(true,Port(8080),AdtB(1),List(1.0, 0.2),Map(key -> value),None))
```

Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/pureconfig/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package object pureconfig {
* `Config` from the configuration files, else a `Failure` with details on why it
* isn't possible
*/
@deprecated("Use `ConfigSource.default.load[Config]` instead", "0.12.0")
def loadConfig[Config](implicit reader: Derivation[ConfigReader[Config]]): ConfigReader.Result[Config] =
ConfigSource.default.load[Config]

Expand Down Expand Up @@ -104,6 +105,7 @@ package object pureconfig {
* @return the configuration
*/
@throws[ConfigReaderException[_]]
@deprecated("Use `ConfigSource.default.loadOrThrow[Config]` instead", "0.12.0")
def loadConfigOrThrow[Config: ClassTag](implicit reader: Derivation[ConfigReader[Config]]): Config =
ConfigSource.default.loadOrThrow[Config]

Expand Down
6 changes: 3 additions & 3 deletions docs/src/main/tut/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ case class ConfC(a: Option[Custom], b: Custom2) extends Conf
When we try to load a `Conf` from a config, we'll simply get this error message:

```tut:book:fail
loadConfig[Conf]
ConfigSource.default.load[Conf]
```

In PureConfig, the derivation of config readers and writers is done by chaining implicits - the converters of larger
Expand All @@ -141,14 +141,14 @@ When code using PureConfig derived converters is compiled using the compiler fla
the dependencies between converters and show a much more helpful message in case of an error:

```scala
loadConfig[Conf]
ConfigSource.default.load[Conf]
// <console>:18: error: could not derive a ConfigReader instance for type Conf, because:
// - missing a ConfigReader instance for type ConfC, because:
// - missing a ConfigReader instance for type Option[Custom], because:
// - missing a ConfigReader instance for type Custom
// - missing a ConfigReader instance for type Custom2
//
// loadConfig[Conf]
// ConfigSource.default.load[Conf]
//
```

Expand Down
3 changes: 2 additions & 1 deletion docs/src/main/tut/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ As a result we recommend only using the latest Scala versions within the minor s
In your code, import `pureconfig.generic.auto` and define data types and a case class to hold the configuration:

```tut:silent
import pureconfig._
import pureconfig.generic.auto._
sealed trait MyAdt
Expand All @@ -42,7 +43,7 @@ resource file of your application (with SBT, they are usually placed in `src/mai
Finally, load the configuration:

```tut:book
pureconfig.loadConfig[MyClass]
ConfigSource.default.load[MyClass]
```

`ConfigReader.Result[MyClass]` is just an alias for `Either[ConfigReaderFailures, MyClass]`, so you can handle it just like you
Expand Down
2 changes: 1 addition & 1 deletion example/src/main/scala/pureconfig/example/conf/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object Main extends App {
case class DirWatchConfig(path: Path, filter: String, email: EmailConfig)
case class EmailConfig(host: String, port: Int, message: String, recipients: Set[Email], sender: Email)

val config = loadConfigOrThrow[Config]
val config = ConfigSource.default.loadOrThrow[Config]

println("dirwatch.path: " + config.dirwatch.path)
println("dirwatch.filter: " + config.dirwatch.filter)
Expand Down

0 comments on commit 0fac76a

Please sign in to comment.