Skip to content

Commit a391cdb

Browse files
committed
Release 0.7.3
1 parent 7f55ab4 commit a391cdb

File tree

11 files changed

+73
-28
lines changed

11 files changed

+73
-28
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ preserving developer-friendly stack traces, and without compromising performance
2121
To use Ox, add the following dependency, using either [sbt](https://www.scala-sbt.org):
2222

2323
```scala
24-
"com.softwaremill.ox" %% "core" % "0.7.2"
24+
"com.softwaremill.ox" %% "core" % "0.7.3"
2525
```
2626

2727
Or [scala-cli](https://scala-cli.virtuslab.org):
2828

2929
```scala
30-
//> using dep "com.softwaremill.ox::core:0.7.2"
30+
//> using dep "com.softwaremill.ox::core:0.7.3"
3131
```
3232

3333
Documentation is available at [https://ox.softwaremill.com](https://ox.softwaremill.com), ScalaDocs can be browsed at [https://javadoc.io](https://www.javadoc.io/doc/com.softwaremill.ox).

generated-doc/out/basics/error-handling.md

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ val result: Either[String, Int] = either:
127127
if v1.ok() > 10 then 42 else "wrong".fail()
128128
```
129129

130-
An exception-throwing expression can be converted to an `Either` using the `.catching[E]` extension method:
130+
### Converting from exceptions
131+
132+
An exception-throwing expression can be converted to an `Either` using the `.catching[E]` extension method (catches
133+
only non-fatal exceptions!):
131134

132135
```scala
133136
import ox.either.catching
@@ -138,12 +141,37 @@ val result: Either[IllegalArgumentException, Int] =
138141
.catching[IllegalArgumentException]
139142
```
140143

141-
Arbitrary exception-throwing code can be converted to an `Either` using `catchingNonFatal`:
144+
Any `try-catch` blocks that you have in your code should be kept as small as possible, so that it's possibly obvious
145+
where the errors might originate. Using `.catching` at the sites where exceptions are thrown helps keeps the syntax
146+
lean and enables pinpointing where exceptions might occur.
147+
148+
An alternative to an `either` block is an `either.catchAll` block which additionally catches any non-fatal exceptions
149+
that occur when evaluating the nested expression. Within the block, both `.ok()` and `.fail()` can be used. The error
150+
type within such block is fixed to `Throwable`:
142151

143152
```scala
144153
import ox.either
154+
import ox.either.ok
155+
156+
def doWork(): Either[Exception, Boolean] = ???
157+
158+
val result: Either[Throwable, String] = either.catchAll:
159+
if doWork().ok() then "ok" else throw new RuntimeException("not ok")
160+
```
161+
162+
## Converting to exceptions
163+
164+
For `Either` instances where the left-side is an exception, the right-value of an `Either` can be unwrapped using `.orThrow`.
165+
The exception on the left side is thrown if it is present:
166+
167+
```scala
168+
import ox.either.orThrow
169+
170+
val v1: Either[Exception, Int] = Right(10)
171+
assert(v1.orThrow == 10)
145172

146-
val result: Either[Throwable, String] = either.catchingNonFatal(throw new RuntimeException("boom"))
173+
val v2: Either[Exception, Int] = Left(new RuntimeException("boom!"))
174+
v2.orThrow // throws RuntimeException("boom!")
147175
```
148176

149177
### Nested `either` blocks
@@ -203,21 +231,6 @@ val outerResult: Either[Exception, Unit] = either:
203231

204232
After this change refactoring `returnsEither` to return `Either[Exception, Int]` would yield a compile error on `returnsEither.ok()`.
205233

206-
## Other `Either` utilities
207-
208-
For `Either` instances where the left-side is an exception, the right-value of an `Either` can be unwrapped using `.orThrow`.
209-
The exception on the left side is thrown if it is present:
210-
211-
```scala
212-
import ox.either.orThrow
213-
214-
val v1: Either[Exception, Int] = Right(10)
215-
assert(v1.orThrow == 10)
216-
217-
val v2: Either[Exception, Int] = Left(new RuntimeException("boom!"))
218-
v2.orThrow // throws RuntimeException("boom!")
219-
```
220-
221234
## Mapping errors
222235

223236
When an `Either` is used to represent errors, these can be mapped by using `.left.map`. This can be used to entirely

generated-doc/out/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Safe direct-style streaming, concurrency and resiliency for Scala on the JVM. Requires JDK 21+ & Scala 3.
44

5-
To start using Ox, add the `com.softwaremill.ox::core:0.7.2` [dependency](info/dependency.md) to your project.
5+
To start using Ox, add the `com.softwaremill.ox::core:0.7.3` [dependency](info/dependency.md) to your project.
66
Then, take a look at the tour of Ox, or follow one of the topics listed in the menu to get to know Ox's API!
77

88
In addition to this documentation, ScalaDocs can be browsed at [https://javadoc.io](https://www.javadoc.io/doc/com.softwaremill.ox).
@@ -92,6 +92,8 @@ In addition to this documentation, ScalaDocs can be browsed at [https://javadoc.
9292
integrations/mdc-logback
9393
integrations/cron4s
9494
integrations/otel-context
95+
integrations/tapir
96+
integrations/sttp-client
9597
9698
.. toctree::
9799
:maxdepth: 2

generated-doc/out/info/dependency.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ To use ox core in your project, add:
44

55
```scala
66
// sbt dependency
7-
"com.softwaremill.ox" %% "core" % "0.7.2"
7+
"com.softwaremill.ox" %% "core" % "0.7.3"
88

99
// scala-cli dependency
10-
//> using dep com.softwaremill.ox::core:0.7.2
10+
//> using dep com.softwaremill.ox::core:0.7.3
1111
```
1212

1313
Ox core depends only on the Java [jox](https://github.com/softwaremill/jox) project, where channels are implemented. There are no other direct or transitive dependencies.

generated-doc/out/integrations/cron4s.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Dependency:
44

55
```scala
6-
"com.softwaremill.ox" %% "cron" % "0.7.2"
6+
"com.softwaremill.ox" %% "cron" % "0.7.3"
77
```
88

99
This module allows to run schedules based on cron expressions from [cron4s](https://github.com/alonsodomin/cron4s).

generated-doc/out/integrations/kafka.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Dependency:
44

55
```scala
6-
"com.softwaremill.ox" %% "kafka" % "0.7.2"
6+
"com.softwaremill.ox" %% "kafka" % "0.7.3"
77
```
88

99
`Flow`s which read from a Kafka topic, mapping stages and drains which publish to Kafka topics are available through

generated-doc/out/integrations/mdc-logback.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Dependency:
44

55
```scala
6-
"com.softwaremill.ox" %% "mdc-logback" % "0.7.2"
6+
"com.softwaremill.ox" %% "mdc-logback" % "0.7.3"
77
```
88

99
Ox provides support for setting inheritable MDC (mapped diagnostic context) values, when using the [Logback](https://logback.qos.ch)

generated-doc/out/integrations/otel-context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Dependency:
44

55
```scala
6-
"com.softwaremill.ox" %% "otel-context" % "0.7.2"
6+
"com.softwaremill.ox" %% "otel-context" % "0.7.3"
77
```
88

99
When using the default OpenTelemetry context-propagation mechanisms, which rely on thread-local storage, the context
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# HTTP client using sttp
2+
3+
[sttp-client](https://sttp.softwaremill.com) is a Scala HTTP client integrating with a number of Scala stacks,
4+
including direct-style backends.
5+
6+
The integration is included in the sttp-client library and includes:
7+
* synchronous backends, which are designed to work with direct-style Scala
8+
* streaming request & response bodies, converted to/from `Flow`s via `InputStream`s
9+
* interacting with WebSockets, either using the `WebSocket` interface directly, or using `Flow`s of web socket frames
10+
* receiving SSE streams as `Flow[ServerSentEvent]`
11+
12+
For more details refer to the sttp-client documentation, specifically:
13+
* [synchronous backends documentation](https://sttp.softwaremill.com/en/latest/backends/synchronous.html)
14+
* [usage examples](https://sttp.softwaremill.com/en/latest/examples.html), tagged with the `Direct` label
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# HTTP server using Tapir
2+
3+
[Tapir](https://tapir.softwaremill.com) is a library for rapidly developing HTTP APIs. It integrates with a number of
4+
Scala stacks, including direct-style server interpreters.
5+
6+
The integration is included in the Tapir library and includes:
7+
* exposing regular HTTP endpoints (consuming/producing JSON etc.)
8+
* streaming request & response bodies, converted to/from `Flow`s via `InputStream`s
9+
* web sockets represented as a transformation between incoming & outgoing `Flow`s of web socket frames
10+
* SSE response bodies
11+
12+
For more details refer to the Tapir documentation, specifically:
13+
* the [netty-server-sync interpreter documentation](https://tapir.softwaremill.com/en/latest/server/netty.html)
14+
* [usage examples](https://tapir.softwaremill.com/en/latest/examples.html), tagged with the `Direct` label
15+
* [tutorials](https://tapir.softwaremill.com/en/latest/tutorials/01_hello_world.html), which mostly use the
16+
direct-style approach

0 commit comments

Comments
 (0)