Skip to content

Commit bc9e948

Browse files
Merge pull request #21 from ParsePlatform/richardross.unity.httpclient.error
Parse error codes from unity using TryParse, to prevent exceptions.
2 parents 4ce5a33 + 3ad2304 commit bc9e948

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Parse/Internal/HttpClient.Unity.cs

100644100755
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ private static HttpStatusCode GetStatusCode(WWW www) {
140140
return (HttpStatusCode)201;
141141
}
142142
String errorCode = Regex.Match(www.error, @"\d+").Value;
143-
return (HttpStatusCode)Int32.Parse(errorCode);
143+
int errorNumber = 0;
144+
if (!Int32.TryParse(errorCode, out errorNumber)) {
145+
return (HttpStatusCode)400;
146+
}
147+
return (HttpStatusCode)errorNumber;
144148
}
145149

146150
/// <summary>

0 commit comments

Comments
 (0)