Commit f78ff2de by Joona Romppanen

UserLoginControl cleanup & better exception handler

1 parent 9f01e3a2
......@@ -5,16 +5,20 @@ namespace MoyaAdminLib
{
public class MoyaApiException : WebException
{
public HttpStatusCode StatusCode { get; set; }
public MoyaApiException()
{
}
public MoyaApiException(string message) : base(message)
public MoyaApiException(string message, HttpStatusCode statusCode) : base(message)
{
StatusCode = statusCode;
}
public MoyaApiException(string message, Exception innerException) : base(message, innerException)
public MoyaApiException(string message, HttpStatusCode statusCode, Exception innerException) : base(message, innerException)
{
StatusCode = statusCode;
}
}
}
......@@ -141,8 +141,7 @@ namespace MoyaAdminLib
if ((int)response.StatusCode < 200 && (int)response.StatusCode >= 300)
{
var message = string.Format("Request failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
throw new MoyaApiException("Request failed", response.StatusCode);
}
using (var responseStream = response.GetResponseStream())
......@@ -171,7 +170,7 @@ namespace MoyaAdminLib
{
var responseValue = StreamToString(responseStream);
Console.WriteLine("Response was " + responseValue);
throw new MoyaApiException(responseValue, e);
throw new WebException(responseValue, e);
}
......
......@@ -60,13 +60,13 @@
this.txtEmail.Name = "txtEmail";
this.txtEmail.Size = new System.Drawing.Size(395, 26);
this.txtEmail.TabIndex = 67;
this.txtEmail.TextChanged += new System.EventHandler(this.txtEmail_TextChanged);
this.txtEmail.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtEmail_KeyUp);
this.txtEmail.TextChanged += new System.EventHandler(this.TxtEmail_TextChanged);
this.txtEmail.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TxtEmail_KeyUp);
//
// timer1
//
this.timer1.Interval = 500;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
this.timer1.Tick += new System.EventHandler(this.Timer1_Tick);
//
// infoLabel
//
......@@ -89,7 +89,7 @@
this.passwordTextBox.Size = new System.Drawing.Size(125, 26);
this.passwordTextBox.TabIndex = 93;
this.passwordTextBox.Visible = false;
this.passwordTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.passwordTextBox_KeyDown);
this.passwordTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PasswordTextBox_KeyDown);
//
// loginButton
//
......@@ -100,7 +100,7 @@
this.loginButton.Text = "Kirjaudu tapahtumaan";
this.loginButton.UseVisualStyleBackColor = true;
this.loginButton.Visible = false;
this.loginButton.Click += new System.EventHandler(this.loginButton_Click);
this.loginButton.Click += new System.EventHandler(this.LoginButton_Click);
//
// forgottenPasswordButton
//
......@@ -121,7 +121,7 @@
this.btnNewProfile.Text = "Lisää omat tiedot";
this.btnNewProfile.UseVisualStyleBackColor = true;
this.btnNewProfile.Visible = false;
this.btnNewProfile.Click += new System.EventHandler(this.btnNewProfile_Click);
this.btnNewProfile.Click += new System.EventHandler(this.BtnNewProfile_Click);
//
// UserLoginControl
//
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!