@@ -125,6 +125,8 @@ public IObservable<AuthenticationResult> LogIn(string usernameOrEmail, string pa
125
125
. SelectMany ( _ => GetUserFromApi ( ) )
126
126
. Catch < UserAndScopes , ApiException > ( firstTryEx =>
127
127
{
128
+ LogError ( firstTryEx , usernameOrEmail ) ;
129
+
128
130
var exception = firstTryEx as AuthorizationException ;
129
131
if ( isEnterprise
130
132
&& exception != null
@@ -201,6 +203,31 @@ public IObservable<AuthenticationResult> LogIn(string usernameOrEmail, string pa
201
203
. PublishAsync ( ) ;
202
204
}
203
205
206
+ void LogError ( ApiException ex , string usernameOrEmail )
207
+ {
208
+ var msg = ex . Message ;
209
+ var apiex = ex as AuthorizationException ;
210
+ if ( apiex != null )
211
+ {
212
+ msg += Environment . NewLine ;
213
+ msg += apiex . ApiError . Message ;
214
+ if ( apiex . ApiError . Errors != null )
215
+ {
216
+ foreach ( var err in apiex . ApiError . Errors )
217
+ {
218
+ msg += Environment . NewLine ;
219
+ msg += err . Message ;
220
+ }
221
+ }
222
+ }
223
+ log . Info ( CultureInfo . InvariantCulture , "Log in to {0} host '{1}' with username '{2}': {3}" ,
224
+ Address . WebUri . Host ,
225
+ Address . ApiUri ,
226
+ usernameOrEmail ,
227
+ msg
228
+ ) ;
229
+ }
230
+
204
231
public IObservable < Unit > LogOut ( )
205
232
{
206
233
if ( ! IsLoggedIn ) return Observable . Return ( Unit . Default ) ;
@@ -260,11 +287,6 @@ IObservable<AuthenticationResult> LoginWithApiUser(UserAndScopes userAndScopes)
260
287
SupportsGist = userAndScopes . Scopes ? . Contains ( "gist" ) ?? true ;
261
288
IsLoggedIn = true ;
262
289
}
263
-
264
- log . Info ( "Log in from cache for login '{0}' to host '{1}' {2}" ,
265
- userAndScopes ? . User ? . Login ?? "(null)" ,
266
- hostAddress . ApiUri ,
267
- result . IsSuccess ( ) ? "SUCCEEDED" : "FAILED" ) ;
268
290
} ) ;
269
291
}
270
292
0 commit comments