• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Feature Request: Trace/Log to include entire exception data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Feature Request: Trace/Log to include entire exception data

    When an exception is thrown inside the OnBarUpdate method, NT8 logs just the exception message.
    Please make it log and trace the entire exception data obtained via exception.ToString()
    Thanks

    #2
    I agree. I think NinjaTrader could probably do a better job capturing and reporting exceptions,
    although I'm still more familiar with NT7 than NT8 ... I was hoping NT8 was better than NT7.

    FWIW, long ago, like everyone else, I used to do this,

    Code:
    protected override void OnStartUp()
    {
    ...my code here...
    }
    
    protected override void OnBarUpdate()
    {
    ...my code here...
    }
    Now, for every indicator and strategy, I wrap every NinjaTrader Framework method
    in a simple try-catch, precisely to compensate for the issues you raise here.

    Code:
    protected override void OnStartUp()
    {
        try {
            OnStartUp_Handler()
        }
        catch (Exception ex) {
            HandleException(ex);
            throw;
        }
    }
    
    protected override void OnBarUpdate()
    {
        try {
            OnBarUpdate_Handler()
        }
        catch (Exception ex) {
            HandleException(ex);
            throw;
        }
    }
    My real code now goes here,

    Code:
    private void OnStartUp_Handler()
    {
    ...my code here...
    }
    
    private void OnBarUpdate_Handler()
    {
    ...my code here...
    }
    So now, I always get full details of the exception, including a stack trace,
    because I wrote my HandleException() method to do exactly that. And I
    can write this information to my own debug log, Ninja's output window, or
    the builtin Log facility ... or any combination thereof ... very convenient.

    [The only real annoyance that is left is this: if your properties do anything
    complicated to cause an exception, then this specific technique can't catch
    that -- you'll need to create try/catch traps specific to those properties.]

    Despite the (very small) additional coding, this technique has been an extremely
    worthwhile addition to my toolkit. I'm sure I'll be continuing to use this technique
    in all my NT8 programming.

    Comment


      #3
      Hello bboyle1234 and bltdavid,

      Thank you for your suggestion.

      I've added a feature request to improve the error logging. This request is being tracked under the number SFT-4653.

      As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

      Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

      Please let us know if we may be of further assistance to you.
      Kate W.NinjaTrader Customer Service

      Comment


        #4
        We usually just print to the Output window with something like this....


        Code:
        try
        {
            // ... Logic here
        }
        catch (Exception ex)
        {
            Print(string.Format("Method name EXCEPTION [{0} / {1}]: Msg: {2}{3}   Trace: {4}", _productName, _version, ex.Message, Environment.NewLine, ex.StackTrace));
        }
        This seems to work pretty well for our needs.
        We've also considered using our own logging mechanism in this scenario.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by renehtx, Today, 03:51 PM
        0 responses
        1 view
        0 likes
        Last Post renehtx
        by renehtx
         
        Started by eidog2020, Today, 03:31 PM
        0 responses
        3 views
        0 likes
        Last Post eidog2020  
        Started by Lowerlevel1, Today, 01:34 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Mykro, Today, 12:33 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_BrendanC  
        Started by madams212121, Today, 12:03 PM
        5 responses
        25 views
        0 likes
        Last Post madams212121  
        Working...
        X