Home > Software design >  Rails 6 get error message from Failure monad results
Rails 6 get error message from Failure monad results

Time:05-19

Is it possible to get error message which was passed as a Failure monad result? as far as I can see the value! method is provided for Success but is it possible to get message from Failure as well?

response[0]
=> Failure("12345 - Product code is not valid")

to be something like:

response[0].message
=> "12345 - Product code is not valid"

CodePudding user response:

To access the Failure message Failure monad provides failure method.

response[0].failure
=> "12345 - Product code is not valid"
  • Related