dev
修訂 | 6c990dcacc895ec4f661d4ee180684fb18f8ad6a (tree) |
---|---|
時間 | 2014-01-30 07:40:02 |
作者 | ANIKITI <anikiti07@gmai...> |
Commiter | ANIKITI |
Twitter.CheckStatusCode メソッドで NullReferenceException がスローされる可能性がある問題を修正
@@ -3214,19 +3214,26 @@ namespace OpenTween | ||
3214 | 3214 | // 404エラーの挙動が変なので無視: https://dev.twitter.com/discussions/1213 |
3215 | 3215 | if (httpStatus == HttpStatusCode.NotFound) return null; |
3216 | 3216 | |
3217 | - var callerMethod = new StackTrace(false).GetFrame(1).GetMethod().Name; | |
3217 | + var callerMethod = new StackTrace(false).GetFrame(1).GetMethod(); | |
3218 | + var callerMethodName = callerMethod != null | |
3219 | + ? callerMethod.Name | |
3220 | + : ""; | |
3218 | 3221 | |
3219 | 3222 | if (string.IsNullOrWhiteSpace(responseText)) |
3220 | 3223 | { |
3221 | 3224 | if (httpStatus == HttpStatusCode.Unauthorized) |
3222 | 3225 | Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid; |
3223 | 3226 | |
3224 | - return "Err:" + httpStatus + "(" + callerMethod + ")"; | |
3227 | + return "Err:" + httpStatus + "(" + callerMethodName + ")"; | |
3225 | 3228 | } |
3226 | 3229 | |
3227 | 3230 | try |
3228 | 3231 | { |
3229 | 3232 | var errors = MyCommon.CreateDataFromJson<TwitterDataModel.ErrorResponse>(responseText).Errors; |
3233 | + if (errors == null || !errors.Any()) | |
3234 | + { | |
3235 | + return "Err:" + responseText + "(" + callerMethodName + ")"; | |
3236 | + } | |
3230 | 3237 | |
3231 | 3238 | foreach (var error in errors) |
3232 | 3239 | { |
@@ -3237,11 +3244,11 @@ namespace OpenTween | ||
3237 | 3244 | } |
3238 | 3245 | } |
3239 | 3246 | |
3240 | - return "Err:" + string.Join(",", errors.Select(x => x.ToString())) + "(" + callerMethod + ")"; | |
3247 | + return "Err:" + string.Join(",", errors.Select(x => x.ToString())) + "(" + callerMethodName + ")"; | |
3241 | 3248 | } |
3242 | 3249 | catch (SerializationException) { } |
3243 | 3250 | |
3244 | - return "Err:" + responseText + "(" + callerMethod + ")"; | |
3251 | + return "Err:" + responseText + "(" + callerMethodName + ")"; | |
3245 | 3252 | } |
3246 | 3253 | |
3247 | 3254 | #region "UserStream" |