added stack trace to exception output in API when YII_DEBUG is true

issues #303 and #2516