Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@luis3m
Copy link
Contributor

@luis3m luis3m commented May 14, 2020

Addresses #2153 (cc @adamgfraser @jdegoes)

@luis3m luis3m force-pushed the exitcode branch 2 times, most recently from 6fd3605 to 84e908a Compare May 14, 2020 16:51
@jdegoes
Copy link
Member

jdegoes commented May 14, 2020

/cc @adamgfraser for the scalafix part

@luis3m luis3m force-pushed the exitcode branch 2 times, most recently from c5106da to f9a1f8a Compare May 14, 2020 17:44
* Maps this effect to the default exit codes.
*/
final def exitCode: URIO[R, ExitCode] =
self.foldCauseM(cause => UIO(println(cause.prettyPrint)) as ExitCode.failure, _ => ZIO.succeedNow(ExitCode.success))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s use putStrLn instead of println here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iravid I took this combinator from #2153, I suspect John suggested println to avoid adding a dependency on Console at the end of your program. OTOH, App uses ZEnv anyway so even if you write program.provideSomeLayer(ZEnv.live ++ customLayers).exitCode it won't crash as Console would be its only missing dependency which the default runtime will provide.

I will update in a few minutes (cc: @jdegoes)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iravid done

@jdegoes jdegoes merged commit 4b17888 into zio:master May 19, 2020
@jdegoes
Copy link
Member

jdegoes commented May 19, 2020

@luis3m Thank you for this wonderful contribution! Much better than Int.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants