| |

VerySource

 Forgot password?
 Register
Search
View: 1732|Reply: 15

try..catch problem

[Copy link]

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-28 20:00:01
| Show all posts |Read mode
That big brother tell me
try
{
  ...
}
catch (Exception ex)
{
   throw ex;
}
What's the difference between not adding try..catch, mainly because I don't understand what to do after catching the exception, then
What's the use of rethrowing?
Reply

Use magic Report

0

Threads

64

Posts

45.00

Credits

Newbie

Rank: 1

Credits
45.00

 China

Post time: 2020-2-24 14:00:02
| Show all posts
No error will be reported on the try..catch page
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 United States

Post time: 2020-2-24 14:15:01
| Show all posts
Can display your customized error message after getting an exception
Reply

Use magic Report

0

Threads

64

Posts

45.00

Credits

Newbie

Rank: 1

Credits
45.00

 China

Post time: 2020-2-24 15:00:01
| Show all posts
You can also implement some functional operations after reporting an error (that is, in Catch)
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-2-24 17:15:01
| Show all posts
The problem is that the same exception is thrown again after try,
Reply

Use magic Report

0

Threads

24

Posts

20.00

Credits

Newbie

Rank: 1

Credits
20.00

 China

Post time: 2020-2-24 17:30:02
| Show all posts
Can display your customized error message after getting an exception

Make users get the teaching experience!
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-2-29 19:15:02
| Show all posts
cath is about to throw an ex;
Reply

Use magic Report

0

Threads

14

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-1 02:00:02
| Show all posts
Is throwing the same exception, but this time it is caught by the outer try
In this way, you can focus on exceptions.
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-3-1 09:15:02
| Show all posts
Maybe I didn't make it clear, my doubt is, after catching the exception, do a rethrow
The same abnormal action, nothing else, so its upper Yi layer to catch the exception,
If this processing is not added, if there is an exception, it is also processed by the previous layer, and it throws
Is the same exception, so what does this try..cacth do?
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 United States

 Author| Post time: 2020-3-1 13:30:01
| Show all posts
If it is not used by the outer layer, it will be useless. I saw this sentence from the demo in the Microsoft lecture.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list