Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sdgd · Feb 05, 2014 at 12:18 PM · c#manualexceptions

how to properly use: System.InvalidOperationException

 public static void Interupt(int Index, string Text){
     try{
         Change(Transforms[ Index ], Text);
     }
     catch{
         throw new System.InvalidOperationException("Index: " + Index + "  Is too large should be less than: " + Transforms.Count);
     }
 }

ok this code points me to

 throw, ...

line

how do I make it to point me to line where the function was called?

like:

 using UnityEngine;
 using System.Collections;
 
 public class TestScript : MonoBehaviour {
     void Start(){
         SomeClass.Interupt(5, ""); // I want it to point me here
     }
 }

THO I did try doing:

 return throw new System.InvalidOperationException("Index: " + Index + "  Is too large should be less than: " + Transforms.Count);

but I get:

 error CS1525: Unexpected symbol `throw'

witch is kinda logical, ...

but how does unity do it so it points you to function instead of throw line?

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Benproductions1 · Feb 08, 2014 at 10:26 AM 0
Share

Why would you want to do this? Just read the entry in the traceback above that function...

avatar image sdgd · Feb 08, 2014 at 10:17 PM 0
Share

traceback?

besides if I read it back all I can see is entry point and I cannot know from where they entered this entry point of the function.

I cannot know from witch function it was called. but I must dig hard in to my code.

avatar image Hoeloe · Feb 08, 2014 at 11:24 PM 0
Share

There's a thing called a stack trace. Look that up. It keeps a log of the stack just before the exception was thrown, and it is structured as a hierarchy of method calls, so if you look at the previous entry in the stack trace, you will find where the code entered the method that threw the error.

avatar image Benproductions1 · Feb 09, 2014 at 08:39 AM 0
Share

@sdgd the traceback is what Unity dumps into the the Debug-Log. In general it's a trace containing each individual item on the stack propagating backwards from the exception that was thrown. As long as this stays within C# you will be able to trace your problem back to it's origins (therefore trace-back).

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

An OS design issue: File types associated with their appropriate programs 1 Answer

Create a manual link for a custom C# script component 1 Answer

C# String Requires Manual Assignment in Inspector 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges