better exception on e.(left|right).get ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

better exception on e.(left|right).get ?

Sadek Drobi

    def get = e match {

126

      case Left(a) => a

127

      case Right(_) =>  throw new NoSuchElementException("Either.left.value on Right")

128

    }


why not include b in the error message, won't it be more informing?
case Right(b) =>  throw new NoSuchElementException("Either.left.value on Right("+b+")")

--
www.sadekdrobi.com
ʎdoɹʇuǝ
Reply | Threaded
Open this post in threaded view
|

Re: better exception on e.(left|right).get ?

Dennis Haupt-2
Am 19.11.2010 21:01, schrieb Sadek Drobi:

    def get = e match {

126

      case Left(a) => a

127

      case Right(_) =>  throw new NoSuchElementException("Either.left.value on Right")

128

    }


why not include b in the error message, won't it be more informing?
case Right(b) =>  throw new NoSuchElementException("Either.left.value on Right("+b+")")

--
www.sadekdrobi.com
ʎdoɹʇuǝ
+1

an exception message should always contain as much information as possible
Reply | Threaded
Open this post in threaded view
|

Re: better exception on e.(left|right).get ?

Sadek Drobi
In reply to this post by Sadek Drobi
Especially that there is no lazyness involved for the b parameter.

On Fri, Nov 19, 2010 at 9:01 PM, Sadek Drobi <[hidden email]> wrote:

    def get = e match {

126

      case Left(a) => a

127

      case Right(_) =>  throw new NoSuchElementException("Either.left.value on Right")

128

    }


why not include b in the error message, won't it be more informing?
case Right(b) =>  throw new NoSuchElementException("Either.left.value on Right("+b+")")

--
www.sadekdrobi.com
ʎdoɹʇuǝ



--
www.sadekdrobi.com
ʎdoɹʇuǝ