Search Results

Search found 4116 results on 165 pages for 'baron throw'.

Page 10/165 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Temporary debug releases and final application releases

    - by baron
    I have a quick question regarding debug and release in VS 2008. I have an app i've been working on - its not yet complete but the bulk of the functionality is there. So basically i'm trying to give a copy of it now to the person helping with documentation - just so they can have a play and get the feel for what i've made. Now the question is how to provide it to them. I was told to just copy the .exe out of the debug/bin folder and put that onto USB. But when testing, if I run this .exe anywhere else (outside of this folder) it crashes. I've now worked out why this is: var path = ConfigurationManager.AppSettings["PathToUse"]; var files = Directory.GetFiles(path); throws a null reference, so that App.config file is not being used. If I copy that file in with the .exe it works again. So actually my question is regarding the best way to manage this situation. What is the best way to provide a working copy to people, and, is there a reference on preparing apps for release - so everything is packaged together and installed in a clean structured folder heirarchy?

    Read the article

  • Batch scripting for directories or better method

    - by baron
    Hi Everyone, Looking at creating a simple batch file for my app. My app needs some directories to be in place as it runs. The first method I thought was just make a batch script: @ECHO OFF IF NOT EXIST C:\App GOTO :CREATE ELSE GOTO :DONTCREATE :CREATE MKDIR C:\App\Code ECHO DIRECTORY CREATED :DONTCREATE ECHO IT WAS ALREADY THERE 1) This doesn't run as I would expect. Both :CREATE and :DONTCREATE seem to run regardless? How do I do an If properly then? Output: A subdirectory or file C:\App\Code already exists. DIRECTORY CREATED IT WAS ALREADY THERE So it enters both true and false statements? 2) The app is a C# WPF app. For what I am trying to do here (create a couple of directories if they don't already exist) - should I do it some other way? Perhaps in the application as it runs?

    Read the article

  • Help with Linq Expression - INotifyPropertyChanged

    - by Stephen Patten
    Hello, I'm reading the source code from the latest Prism 4 drop and am interested in solving this problem. There is a base class for the ViewModels that implements INotifyPropertyChanged and INotifyDataErrorInfo and provides some refactoring friendly change notification. protected void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpresssion) { var propertyName = ExtractPropertyName(propertyExpresssion); this.RaisePropertyChanged(propertyName); } private string ExtractPropertyName<T>(Expression<Func<T>> propertyExpresssion) { if (propertyExpresssion == null) { throw new ArgumentNullException("propertyExpression"); } var memberExpression = propertyExpresssion.Body as MemberExpression; if (memberExpression == null) { throw new ArgumentException("The expression is not a member access expression.", "propertyExpression"); } var property = memberExpression.Member as PropertyInfo; if (property == null) { throw new ArgumentException("The member access expression does not access property.","propertyExpression"); } if (!property.DeclaringType.IsAssignableFrom(this.GetType())) { throw new ArgumentException("The referenced property belongs to a different type.", "propertyExpression"); } var getMethod = property.GetGetMethod(true); if (getMethod == null) { // this shouldn't happen - the expression would reject the property before reaching this far throw new ArgumentException("The referenced property does not have a get method.", "propertyExpression"); } if (getMethod.IsStatic) { throw new ArgumentException("The referenced property is a static property.", "propertyExpression"); } return memberExpression.Member.Name; } and as an example of it's usage private void RetrieveNewQuestionnaire() { this.Questions.Clear(); var template = this.questionnaireService.GetQuestionnaireTemplate(); this.questionnaire = new Questionnaire(template); foreach (var question in this.questionnaire.Questions) { this.Questions.Add(this.CreateQuestionViewModel(question)); } this.RaisePropertyChanged(() => this.Name); this.RaisePropertyChanged(() => this.UnansweredQuestions); this.RaisePropertyChanged(() => this.TotalQuestions); this.RaisePropertyChanged(() => this.CanSubmit); } My question is this. What would it take to pass an array of the property names to an overloaded method (RaisePropertyChanged) and condense this last bit of code from 4 lines to 1? Thank you, Stephen

    Read the article

  • Deploying web service

    - by baron
    I am trying to build a webservice that manipulates http requests POST and GET. Here is a sample: public class CodebookHttpHandler: IHttpHandler { public void ProcessRequest(HttpContext context) { if (context.Request.HttpMethod == "POST") { //DoHttpPostLogic(); } else if (context.Request.HttpMethod == "GET") { //DoHttpGetLogic(); } } ... public void DoHttpPostLogic() { ... } public void DoHttpGetLogic() { ... } I need to deploy this but I am struggling how to start. Most online references show making a website, but really, all I want to do is respond when an HttpPost is sent. I don't know what to put in the website, just want that code to run. Some links i've tried so far: http://my.execpc.com/~gopalan/dotnet/webservices/webservice_server.html http://www.beansoftware.com/asp.net-tutorials/deploy-asp.net.aspx http://msdn.microsoft.com/en-us/library/6x71sze4%28VS.80%29.aspx http://www.c-sharpcorner.com/UploadFile/rajaduraip/SimplestwaytoCreateNDeployWebServices12232005054219AM/SimplestwaytoCreateNDeployWebServices.aspx

    Read the article

  • Writing catch block with cleanup operations in Java ...

    - by kedarmhaswade
    I was not able to find any advise on catch blocks in Java that involve some cleanup operations which themselves could throw exceptions. The classic example is that of stream.close() which we usually call in the finally clause and if that throws an exception, we either ignore it by calling it in a try-catch block or declare it to be rethrown. But in general, how do I handle cases like: public void doIt() throws ApiException { //ApiException is my "higher level" exception try { doLower(); } catch(Exception le) { doCleanup(); //this throws exception too which I can't communicate to caller throw new ApiException(le); } } I could do: catch(Exception le) { try { doCleanup(); } catch(Exception e) { //ignore? //log? } throw new ApiException(le); //I must throw le } But that means I will have to do some log analysis to understand why cleanup failed. If I did: catch(Exception le) { try { doCleanup(); } catch(Exception e) { throw new ApiException(e); } It results in losing the le that got me here in the catch block in the fist place. What are some of the idioms people use here? Declare the lower level exceptions in throws clause? Ignore the exceptions during cleanup operation?

    Read the article

  • HTTP Error 403.1 - Permissions are fixed, what else is wrong?

    - by baron
    I have developed a HTTP Handler Web Service, and have had it successfully deployed, through testing on other environments i've ran into another problem. This is the error message I receive: You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed. HTTP Error 403.1 - Forbidden: Execute access is denied. Internet Information Services (IIS) So it is obvious what needs to be fixed, so: 1) Start Internet Information Services (IIS) Manager. 2) Right-click the Web site that contains the SharePoint Web site that you created, and then click Properties. 3) Click the Home Directory tab. 4) Under Application settings, click either Scripts only in the Execute permissions list or Scripts and Executables in the Execute permissions list (as appropriate to your situation). Click OK. 5) Quit IIS Manager. But I'm still getting the same error. So what else could be wrong?

    Read the article

  • Pyplot connect to timer event?

    - by Baron Yugovich
    The same way I now have plt.connect('button_press_event', self.on_click) I would like to have something like plt.connect('each_five_seconds_event', self.on_timer) How can I achieve this in a way that's most similar to what I've shown above? EDIT: I tried fig = plt.subplot2grid((num_cols, num_rows), (col, row), rowspan=rowspan, colspan=colspan) timer = fig.canvas.new_timer(interval=100, callbacks=[(self.on_click)]) timer.start() And got AttributeError: 'AxesSubplot' object has no attribute 'canvas'

    Read the article

  • How can i return abstract class from any factory?

    - by programmerist
    using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace EfTestFactory { public abstract class _Company { public abstract List<Personel> GetPersonel(); public abstract List<Prim> GetPrim(); public abstract List<Finans> GetFinans(); } public abstract class _Radyoloji { public abstract List<string> GetRadyoloji(); } public abstract class _Satis { public abstract List<string> GetSatis(); } public abstract class _Muayene { public abstract List<string> GetMuayene(); } public class Company : _Company { public override List<Personel> GetPersonel() { throw new NotImplementedException(); } public override List<Prim> GetPrim() { throw new NotImplementedException(); } public override List<Finans> GetFinans() { throw new NotImplementedException(); } } public class Radyoloji : _Radyoloji { public override List<string> GetRadyoloji() { throw new NotImplementedException(); } } public class Satis : _Satis { public override List<string> GetSatis() { throw new NotImplementedException(); } } public class Muayene : _Muayene { public override List<string> GetMuayene() { throw new NotImplementedException(); } } public class GenoTipController { public object CreateByEnum(DataModelType modeltype) { string enumText = modeltype.ToString(); // will return for example "Company" Type classType = Type.GetType(enumText); // the Type for Company class object t = Activator.CreateInstance(classType); // create an instance of Company class return t; } } public class AntsController { static Dictionary<DataModelType, Func<object>> s_creators = new Dictionary<DataModelType, Func<object>>() { { DataModelType.Radyoloji, () => new _Radyoloji() }, { DataModelType.Company, () => new _Company() }, { DataModelType.Muayene, () => new _Muayene() }, { DataModelType.Satis, () => new _Satis() }, }; public object CreateByEnum(DataModelType modeltype) { return s_creators[modeltype](); } } public class CompanyView { public static List<Personel> GetPersonel() { GenoTipController controller = new GenoTipController(); _Company company = controller.CreateByEnum(DataModelType.Company) as _Company; return company.GetPersonel(); } } public enum DataModelType { Radyoloji, Satis, Muayene, Company } } if i write above codes i see some error: Cannot create an instance of abstract class or interface 'EfTestFactory_Company'How can i solve it? Look please below pic.

    Read the article

  • SImplifying with LINQ - Basic selection

    - by baron
    Hello foreach (var person in peopleList.Where(person => person.FirstName == "Messi")) { selectPeople.Add(person); } I am just wondering if there is any way to simplify this using LINQ. Like rather than look at all the people I was trying to use LINQ to just fill a list with the "Messi"'s... was trying something like... var selectPeople = peopleList.Select(x=>x.FirstName=="Messi"); Then I could just add everyone in that list without a check. But it doesn't quite work as planned. Maybe there's no point simplifying that expression. But the question seemed worthwhile just to strengthen my LINQ knowledge.

    Read the article

  • How safe is my safe rethrow?

    - by gustafc
    (Late edit: This question will hopefully be obsolete when Java 7 comes, because of the "final rethrow" feature which seems like it will be added.) Quite often, I find myself in situations looking like this: do some initialization try { do some work } catch any exception { undo initialization rethrow exception } In C# you can do it like this: InitializeStuff(); try { DoSomeWork(); } catch { UndoInitialize(); throw; } For Java, there's no good substitution, and since the proposal for improved exception handling was cut from Java 7, it looks like it'll take at best several years until we get something like it. Thus, I decided to roll my own: (Edit: Half a year later, final rethrow is back, or so it seems.) public final class Rethrow { private Rethrow() { throw new AssertionError("uninstantiable"); } /** Rethrows t if it is an unchecked exception. */ public static void unchecked(Throwable t) { if (t instanceof Error) throw (Error) t; if (t instanceof RuntimeException) throw (RuntimeException) t; } /** Rethrows t if it is an unchecked exception or an instance of E. */ public static <E extends Exception> void instanceOrUnchecked( Class<E> exceptionClass, Throwable t) throws E, Error, RuntimeException { Rethrow.unchecked(t); if (exceptionClass.isInstance(t)) throw exceptionClass.cast(t); } } Typical usage: public void doStuff() throws SomeException { initializeStuff(); try { doSomeWork(); } catch (Throwable t) { undoInitialize(); Rethrow.instanceOrUnchecked(SomeException.class, t); // We shouldn't get past the above line as only unchecked or // SomeException exceptions are thrown in the try block, but // we don't want to risk swallowing an error, so: throw new SomeException("Unexpected exception", t); } private void doSomeWork() throws SomeException { ... } } It's a bit wordy, catching Throwable is usually frowned upon, I'm not really happy at using reflection just to rethrow an exception, and I always feel a bit uneasy writing "this will not happen" comments, but in practice it works well (or seems to, at least). What I wonder is: Do I have any flaws in my rethrow helper methods? Some corner cases I've missed? (I know that the Throwable may have been caused by something so severe that my undoInitialize will fail, but that's OK.) Has someone already invented this? I looked at Commons Lang's ExceptionUtils but that does other things. Edit: finally is not the droid I'm looking for. I'm only interested to do stuff when an exception is thrown. Yes, I know catching Throwable is a big no-no, but I think it's the lesser evil here compared to having three catch clauses (for Error, RuntimeException and SomeException, respectively) with identical code. Note that I'm not trying to suppress any errors - the idea is that any exceptions thrown in the try block will continue to bubble up through the call stack as soon as I've rewinded a few things.

    Read the article

  • java checked exception in a catch clause compilation error

    - by srandpersonia
    Hi, I was expecting an compilation error in the following program because of the throw statement in the catch block as IOException is a checked exception and it is not caught by another try block within the catch block. But I am getting "Hurray!" printed. Any explanation would be much appreciated. According to JLS 11.2.3, http://java.sun.com/docs/books/jls/third_edition/html/exceptions.html It is a compile-time error if a method or constructor body can throw some exception type E when both of the following hold: * E is a checked exception type * E is not a subtype of some type declared in the throws clause of the method or constructor. import java.io.*; public class Test{ public static void main(String args[]) { System.out.println(method()); } public static int method() { try{ throw new Exception(); } catch(Exception e){ throw new IOException(); //No compile time error } finally{ System.out.println("Hurray!"); } } } Thanks in advance.

    Read the article

  • Multiline for WPF TextBox

    - by baron
    I am developing a app for sending some feedback. Basically i'm trying to make a TextBox for comments, but i'm used to the WinForms MultiLine=true. I've set MinLines to 3, which is getting there, but preferably i'd like if user is able to type wherever in this block, like press enter and do dot points sort of thing - like: - Item 1 blah - Item 2 blahlb lahbvl d But at the moment the text all stays on one line. - Item 1 blah - Item 2 blahb blahb blah This comments will then help fill the body of an email which is sent. It may be pointless if I can't easily keep the same formatting when putting this string into the email body string (so that it looks like it does when sent as it does when typed). Can I achieve what I'm after or do I have to leave it as all text on one line?

    Read the article

  • Fast ArgumentNullException with attributes. It is possible?

    - by Fraga
    Hi. Is there any fast way to verify null arguments via attributes or something? Convert this: public void Method(type arg1,type arg2,type arg3) { if (arg1== null) throw new ArgumentNullException("arg1"); if (arg2== null) throw new ArgumentNullException("arg2"); if (arg3== null) throw new ArgumentNullException("arg3"); //Business Logic } Into something like this: [VerifyNullArgument("arg1","arg2","arg3")] public void Method(type arg1,type arg2,type arg3) { //Business Logic } Ideas? thanks guys.

    Read the article

  • Unable to use nMock GetProperty routine on a property of an inherited object...

    - by Chris
    I am getting this error when trying to set an expectation on an object I mocked that inherits from MembershipUser: ContactRepositoryTests.UpdateTest : FailedSystem.InvalidProgramException: JIT Compiler encountered an internal limitation. Server stack trace: at MockObjectType1.ToString() Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(ref MessageData msgData, Int32 type) at System.Object.ToString() at NMock2.Internal.ExpectationBuilder.On(Object receiver) Here are the tools I am using... VS2008 (SP1) Framework 3.5 nUnit 2.4.8 nMock 2.0.0.44 Resharper 4.1 I am at a loss as to why this would be happening. Any help would be appreciated. Test Class... [TestFixture] public class AddressRepositoryTests { private Mockery m_Mockery; private Data.IAddress m_MockDataAddress; private IUser m_MockUser; [SetUp] public void Setup() { m_Mockery = new Mockery(); m_MockDataAddress = m_Mockery.NewMock<Data.IAddress>(); m_MockUser = m_Mockery.NewMock<IUser>(); } [TearDown] public void TearDown() { m_Mockery.Dispose(); } [Test] public void CreateTest() { string line1 = "unitTestLine1"; string line2 = "unitTestLine2"; string city = "unitTestCity"; int stateId = 1893; string postalCode = "unitTestPostalCode"; int countryId = 223; bool active = false; int createdById = 1; Expect.Once .On(m_MockUser) .GetProperty("Identity") .Will(Return.Value(createdById)); Expect.Once .On(m_MockDataAddress) .Method("Insert") .With( line1, line2, city, stateId, postalCode, countryId, active, createdById, Is.Anything ) .Will(Return.Value(null)); IAddressRepository addressRepository = new AddressRepository(m_MockDataAddress); IAddress address = addressRepository.Create( line1, line2, city, stateId, postalCode, countryId, active, m_MockUser ); Assert.IsNull(address); } } User Class... public interface IUser { int? Identity { get; set; } int? CreatedBy { get; set; } DateTime CreatedOn { get; set; } int? ModifiedBy { get; set; } DateTime? ModifiedOn { get; set; } string UserName { get; } object ProviderUserKey { get; } string Email { get; set; } string PasswordQuestion { get; } string Comment { get; set; } bool IsApproved { get; set; } bool IsLockedOut { get; } DateTime LastLockoutDate { get; } DateTime CreationDate { get; } DateTime LastLoginDate { get; set; } DateTime LastActivityDate { get; set; } DateTime LastPasswordChangedDate { get; } bool IsOnline { get; } string ProviderName { get; } string ToString(); string GetPassword(); string GetPassword(string passwordAnswer); bool ChangePassword(string oldPassword, string newPassword); bool ChangePasswordQuestionAndAnswer(string password, string newPasswordQuestion, string newPasswordAnswer); string ResetPassword(string passwordAnswer); string ResetPassword(); bool UnlockUser(); } public class User : MembershipUser, IUser { #region Public Properties private int? m_Identity; public int? Identity { get { return m_Identity; } set { if (value <= 0) throw new Exception("Address.Identity must be greater than 0."); m_Identity = value; } } public int? CreatedBy { get; set; } private DateTime m_CreatedOn = DateTime.Now; public DateTime CreatedOn { get { return m_CreatedOn; } set { m_CreatedOn = value; } } public int? ModifiedBy { get; set; } public DateTime? ModifiedOn { get; set; } #endregion Public Properties #region Public Constructors public User() { } #endregion Public Constructors } Address Class... public interface IAddress { int? Identity { get; set; } string Line1 { get; set; } string Line2 { get; set; } string City { get; set; } string PostalCode { get; set; } bool Active { get; set; } int? CreatedBy { get; set; } DateTime CreatedOn { get; set; } int? ModifiedBy { get; set; } DateTime? ModifiedOn { get; set; } } public class Address : IAddress { #region Public Properties private int? m_Identity; public int? Identity { get { return m_Identity; } set { if (value <= 0) throw new Exception("Address.Identity must be greater than 0."); m_Identity = value; } } public string Line1 { get; set; } public string Line2 { get; set; } public string City { get; set; } public string PostalCode { get; set; } public bool Active { get; set; } public int? CreatedBy { get; set; } private DateTime m_CreatedOn = DateTime.Now; public DateTime CreatedOn { get { return m_CreatedOn; } set { m_CreatedOn = value; } } public int? ModifiedBy { get; set; } public DateTime? ModifiedOn { get; set; } #endregion Public Properties } AddressRepository Class... public interface IAddressRepository { IAddress Create(string line1, string line2, string city, int stateId, string postalCode, int countryId, bool active, IUser createdBy); } public class AddressRepository : IAddressRepository { #region Private Properties private Data.IAddress m_DataAddress; private Data.IAddress DataAddress { get { if (m_DataAddress == null) m_DataAddress = new Data.Address(); return m_DataAddress; } set { m_DataAddress = value; } } #endregion Private Properties #region Public Constructor public AddressRepository() { } public AddressRepository(Data.IAddress dataAddress) { DataAddress = dataAddress; } #endregion Public Constructor #region Public Methods public IAddress Create(string line1, string line2, string city, int stateId, string postalCode, int countryId, bool active, IUser createdBy) { if (String.IsNullOrEmpty(line1)) throw new Exception("You must enter a Address Line 1 to register."); if (String.IsNullOrEmpty(city)) throw new Exception("You must enter a City to register."); if (stateId <= 0) throw new Exception("You must select a State to register."); if (String.IsNullOrEmpty(postalCode)) throw new Exception("You must enter a Postal Code to register."); if (countryId <= 0) throw new Exception("You must select a Country to register."); DataSet dataSet = DataAddress.Insert( line1, line2, city, stateId, postalCode, countryId, active, createdBy.Identity, DateTime.Now ); return null; } #endregion Public Methods } DataAddress Class... public interface IAddress { DataSet GetByAddressId (int? AddressId); DataSet Update (int? AddressId, string Address1, string Address2, string City, int? StateId, string PostalCode, int? CountryId, bool? IsActive, Guid? ModifiedBy); DataSet Insert (string Address1, string Address2, string City, int? StateId, string PostalCode, int? CountryId, bool? IsActive, int? CreatedBy, DateTime? CreatedOn); } public class Address : IAddress { public DataSet GetByAddressId (int? AddressId) { Database database = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = database.GetStoredProcCommand("prAddress_GetByAddressId"); DataSet dataSet; try { database.AddInParameter(dbCommand, "AddressId", DbType.Int32, AddressId); dataSet = database.ExecuteDataSet(dbCommand); } catch (SqlException sqlException) { string callMessage = "prAddress_GetByAddressId " + "@AddressId = " + AddressId; throw new Exception(callMessage, sqlException); } return dataSet; } public DataSet Update (int? AddressId, string Address1, string Address2, string City, int? StateId, string PostalCode, int? CountryId, bool? IsActive, Guid? ModifiedBy) { Database database = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = database.GetStoredProcCommand("prAddress_Update"); DataSet dataSet; try { database.AddInParameter(dbCommand, "AddressId", DbType.Int32, AddressId); database.AddInParameter(dbCommand, "Address1", DbType.AnsiString, Address1); database.AddInParameter(dbCommand, "Address2", DbType.AnsiString, Address2); database.AddInParameter(dbCommand, "City", DbType.AnsiString, City); database.AddInParameter(dbCommand, "StateId", DbType.Int32, StateId); database.AddInParameter(dbCommand, "PostalCode", DbType.AnsiString, PostalCode); database.AddInParameter(dbCommand, "CountryId", DbType.Int32, CountryId); database.AddInParameter(dbCommand, "IsActive", DbType.Boolean, IsActive); database.AddInParameter(dbCommand, "ModifiedBy", DbType.Guid, ModifiedBy); dataSet = database.ExecuteDataSet(dbCommand); } catch (SqlException sqlException) { string callMessage = "prAddress_Update " + "@AddressId = " + AddressId + ", @Address1 = " + Address1 + ", @Address2 = " + Address2 + ", @City = " + City + ", @StateId = " + StateId + ", @PostalCode = " + PostalCode + ", @CountryId = " + CountryId + ", @IsActive = " + IsActive + ", @ModifiedBy = " + ModifiedBy; throw new Exception(callMessage, sqlException); } return dataSet; } public DataSet Insert (string Address1, string Address2, string City, int? StateId, string PostalCode, int? CountryId, bool? IsActive, int? CreatedBy, DateTime? CreatedOn) { Database database = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = database.GetStoredProcCommand("prAddress_Insert"); DataSet dataSet; try { database.AddInParameter(dbCommand, "Address1", DbType.AnsiString, Address1); database.AddInParameter(dbCommand, "Address2", DbType.AnsiString, Address2); database.AddInParameter(dbCommand, "City", DbType.AnsiString, City); database.AddInParameter(dbCommand, "StateId", DbType.Int32, StateId); database.AddInParameter(dbCommand, "PostalCode", DbType.AnsiString, PostalCode); database.AddInParameter(dbCommand, "CountryId", DbType.Int32, CountryId); database.AddInParameter(dbCommand, "IsActive", DbType.Boolean, IsActive); database.AddInParameter(dbCommand, "CreatedBy", DbType.Int32, CreatedBy); database.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, CreatedOn); dataSet = database.ExecuteDataSet(dbCommand); } catch (SqlException sqlException) { string callMessage = "prAddress_Insert " + "@Address1 = " + Address1 + ", @Address2 = " + Address2 + ", @City = " + City + ", @StateId = " + StateId + ", @PostalCode = " + PostalCode + ", @CountryId = " + CountryId + ", @IsActive = " + IsActive + ", @CreatedBy = " + CreatedBy + ", @CreatedOn = " + CreatedOn; throw new Exception(callMessage, sqlException); } return dataSet; } }

    Read the article

  • Catch Multiple Custom Exceptions? - C++

    - by Alex
    Hi all, I'm a student in my first C++ programming class, and I'm working on a project where we have to create multiple custom exception classes, and then in one of our event handlers, use a try/catch block to handle them appropriately. My question is: How do I catch my multiple custom exceptions in my try/catch block? GetMessage() is a custom method in my exception classes that returns the exception explanation as a std::string. Below I've included all the relevant code from my project. Thanks for your help! try/catch block // This is in one of my event handlers, newEnd is a wxTextCtrl try { first.ValidateData(); newEndT = first.ComputeEndTime(); *newEnd << newEndT; } catch (// don't know what do to here) { wxMessageBox(_(e.GetMessage()), _("Something Went Wrong!"), wxOK | wxICON_INFORMATION, this);; } ValidateData() Method void Time::ValidateData() { int startHours, startMins, endHours, endMins; startHours = startTime / MINUTES_TO_HOURS; startMins = startTime % MINUTES_TO_HOURS; endHours = endTime / MINUTES_TO_HOURS; endMins = endTime % MINUTES_TO_HOURS; if (!(startHours <= HOURS_MAX && startHours >= HOURS_MIN)) throw new HourOutOfRangeException("Beginning Time Hour Out of Range!"); if (!(endHours <= HOURS_MAX && endHours >= HOURS_MIN)) throw new HourOutOfRangeException("Ending Time Hour Out of Range!"); if (!(startMins <= MINUTE_MAX && startMins >= MINUTE_MIN)) throw new MinuteOutOfRangeException("Starting Time Minute Out of Range!"); if (!(endMins <= MINUTE_MAX && endMins >= MINUTE_MIN)) throw new MinuteOutOfRangeException("Ending Time Minute Out of Range!"); if(!(timeDifference <= P_MAX && timeDifference >= P_MIN)) throw new PercentageOutOfRangeException("Percentage Change Out of Range!"); if (!(startTime < endTime)) throw new StartEndException("Start Time Cannot Be Less Than End Time!"); } Just one of my custom exception classes, the others have the same structure as this one class HourOutOfRangeException { public: // param constructor // initializes message to passed paramater // preconditions - param will be a string // postconditions - message will be initialized // params a string // no return type HourOutOfRangeException(string pMessage) : message(pMessage) {} // GetMessage is getter for var message // params none // preconditions - none // postconditions - none // returns string string GetMessage() { return message; } // destructor ~HourOutOfRangeException() {} private: string message; };

    Read the article

  • Should java try blocks be scoped as tightly as possible?

    - by isme
    I've been told that there is some overhead in using the Java try-catch mechanism. So, while it is necessary to put methods that throw checked exception within a try block to handle the possible exception, it is good practice performance-wise to limit the size of the try block to contain only those operations that could throw exceptions. I'm not so sure that this is a sensible conclusion. Consider the two implementations below of a function that processes a specified text file. Even if it is true that the first one incurs some unnecessary overhead, I find it much easier to follow. It is less clear where exactly the exceptions come from just from looking at statements, but the comments clearly show which statements are responsible. The second one is much longer and complicated than the first. In particular, the nice line-reading idiom of the first has to be mangled to fit the readLine call into a try block. What is the best practice for handling exceptions in a funcion where multiple exceptions could be thrown in its definition? This one contains all the processing code within the try block: void processFile(File f) { try { // construction of FileReader can throw FileNotFoundException BufferedReader in = new BufferedReader(new FileReader(f)); // call of readLine can throw IOException String line; while ((line = in.readLine()) != null) { process(line); } } catch (FileNotFoundException ex) { handle(ex); } catch (IOException ex) { handle(ex); } } This one contains only the methods that throw exceptions within try blocks: void processFile(File f) { FileReader reader; try { reader = new FileReader(f); } catch (FileNotFoundException ex) { handle(ex); return; } BufferedReader in = new BufferedReader(reader); String line; while (true) { try { line = in.readLine(); } catch (IOException ex) { handle(ex); break; } if (line == null) { break; } process(line); } }

    Read the article

  • How can I debug this web service http handler?

    - by baron
    Hello everyone, I am building a Httphandler following these instructions here It manipulates HTTP POST and HTTP GET. I have a client with two buttons two POST and GET. After i've tested and happy everythings working I move it from localhost to IIS. Now when I do this I get an exception in the POST handler code. How on earth can I debug this code line by line? I managed to do this awhile ago, I thought it was by attaching to process but I can't work it out. I can emulate GET just by typing address in browser, post im not sure about. I've tried telnetting and sending it from there but haven't had any luck.

    Read the article

  • Exception handling protocol for methods

    - by athena
    Is there any specific protocol for handling exceptions in public methods? Consider this eg. public int someMethod() { try{ code that might throw an exception } catch(Exception e) { log the exception } } Say that this method might throw an ArrayIndexOutOfBoundsException. So, is it correct to handle this Exception in the method itself (as in the example) or throw it and assume that the calling method will handle the Exception?

    Read the article

  • Java Constructor Style (Check parameters aren't null)

    - by Peter
    What are the best practices if you have a class which accepts some parameters but none of them are allowed to be null? The following is obvious but the exception is a little unspecific: public class SomeClass { public SomeClass(Object one, Object two) { if (one == null || two == null) { throw new IllegalArgumentException("Parameters can't be null"); } //... } } Here the exceptions let you know which parameter is null, but the constructor is now pretty ugly: public class SomeClass { public SomeClass(Object one, Object two) { if (one == null) { throw new IllegalArgumentException("one can't be null"); } if (two == null) { throw new IllegalArgumentException("two can't be null"); } //... } Here the constructor is neater, but now the constructor code isn't really in the constructor: public class SomeClass { public SomeClass(Object one, Object two) { setOne(one); setTwo(two); } public void setOne(Object one) { if (one == null) { throw new IllegalArgumentException("one can't be null"); } //... } public void setTwo(Object two) { if (two == null) { throw new IllegalArgumentException("two can't be null"); } //... } } Which of these styles is best? Or is there an alternative which is more widely accepted? Cheers, Pete

    Read the article

  • Inheritance and choose constructor from base class

    - by myle
    My question is rather simple, but I am stuck. How can I choose the desired constructor from base class? // node.h #ifndef NODE_H #define NODE_H #include <vector> // definition of an exception-class class WrongBoundsException { }; class Node { public: ... Node(double, double, std::vector<double>&) throw (WrongBoundsException); ... }; #endif // InternalNode.h #ifndef INTERNALNODE_H #define INTERNALNODE_H #include <vector> #include "Node.h" class InternalNode : public Node { public: // the position of the leftmost child (child left) int left_child; // the position of the parent int parent; InternalNode(double, double, std::vector<double>&, int parent, int left_child) throw (WrongBoundsException); private: int abcd; }; #endif // InternalNode.cpp #include "InternalNode.h" #define UNDEFINED_CHILD -1 #define ROOT -1 // Here is the problem InternalNode::InternalNode(double a, double b, std::vector<double> &v, int par, int lc) throw (WrongBoundsException) : Node(a, b, v), parent(par), left_child(lc) { std::cout << par << std::endl; } I get: $ g++ InternalNode.cpp InternalNode.cpp:16: error: declaration of ‘InternalNode::InternalNode(double, double, std::vector &, int, int) throw (WrongBoundsException)’ throws different exceptions InternalNode.h:17: error: from previous declaration ‘InternalNode::InternalNode(double, double, std::vector &, int, int)’ UPDATE 0: Fixed missing : UPDATE 1: Fixed throw exception

    Read the article

  • Using open source SNES emulator code to turn a rom file into a self-contained executable game

    - by Baron von Monkeydorf
    Would it be possible to take the source code from a SNES emulator (or any other game system emulator for that matter) and a game ROM for the system, and somehow create a single self-contained executable that lets you play that particular ROM without needing either the individual rom or the emulator itself to play? Would it be difficult, assuming you've already got the rom and the emulator source code to work with?

    Read the article

  • Avoid application becoming unresponsive on download

    - by baron
    Hi I have an application which downloads a file from a network location and then displays that files information. It uses WebClient.DownloadFile to achieve this. The problem is, when the user clicks a button to start the download, the application becomes unresponsive until the file has downloaded. This gives the impression the application may have hung. I would like to seek ideas which would avoid this scenario. Though my solution will need to be 'as quick and cheap as possible' I would be interested in hearing about custom loaders that have been built, or some sort of loading symbol / progress bar / sand time clock thingy : ) Thanks for reading.

    Read the article

  • Help with DateTime in format I need

    - by baron
    I am working with DateTime, trying to get date in the format like this: 03.05.2010-04.05.23 that is: dd.MM.yyyy-HH.mm.ss I'm using DateTime.ParseExact to try to achieve this (maybe wrong) So far I have: var dateInFormat = DateTime.ParseExact(DateTime.Now.ToShortDateString(), "dd.MM.yyyy.HH.mm.ss", null); But can't quite get exactly what I want. Basically I want to keep the 0, for example time is 05:03:20 PM I don't want it to show like 5:3:20 PM Any ideas?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >