title: How to get error message in a string in golang?
body: <p>I referred this question - <a href="https://stackoverflow.com/questions/6012692/os-error-string-value-golang">os.Error - string value (Golang)</a>, but that is not working in my case.</p>
  
  <pre><code>func (t Trans) TicketQty() (intQty int, err string) {
    defer func() {    
      str := recover()
      if(str != nil){     
        err = "an error"
      }
    }()   
    Qty := t.TransObject["qty"].(map[string] interface{})["ticket fv"].(float64)  
    intQty = 10
    return 
  }
  </code></pre>
  
  <p>In that <code>err</code> I need the error message that is thrown, e.g. if the parsing logic fails, it is throwing an error automatically. That is the error I need to catch. I am showing this only for example - whatever the runtime exception is, I need to catch it and pass as <code>err</code> in the return.</p>
  
  <p>How to achieve that?</p>