John H. Brennan
Louis Philippe Dandenault

Learning Scala by Jason Swartz

Learning Scala by Jason Swartz

Author:Jason Swartz
Language: eng
Format: epub
Tags: COMPUTERS / Programming Languages / Java
ISBN: 9781449367923
Publisher: O’Reilly Media
Published: 2014-12-11T05:00:00+00:00

Match expressions

nextError match { case util.Success(x) => x; case util.Failure(error) => -1 }

Use a match expression to handle a Success with a return value (stored in “x”) or a Failure with an exception (stored in “error”). Not shown: logging the error with a good logging framework, ensuring it gets noticed and tracked.

Do nothing


This is the easiest error-handling method of all and a personal favorite of mine. To use this method, simply allow the exception to propagate up the call stack until it gets caught or causes the current application to exit. This method may be too disruptive for certain sensitive cases, but ensures that thrown exceptions will never be ignored.


Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.