Why can't we say 'recue exception => e'?

Asked 2 years ago, Updated 2 years ago, 77 views

Why can't we do resue exception=> e?

Once the server is turned, I want to keep it running without stopping, but when I looked it up, there was no explanation in the data.

Don’t rescue Exception. EVER. or I will stab you.

That's what it said. There is no explanation, so why can't I do resue exception=> e? Then please tell me how to solve my problem

exception-handling ruby

2022-09-21 18:34

1 Answers

Exception is the root of the exception structure of ruby, so acceptException will retrieve all exceptions.

Here, the target to be recorded is from the user's ctrl+c

It includes SyntaxError, LoadError, and Interrupt.

You said you wanted to stop the server when you wanted it, but you can't stop it.

I think you asked me to log, but then you can use resue Standard Error.

begin
  # # iceberg!
rescue => e
  # # lifeboats
end
begin
  # # iceberg!
rescue StandardError => e
  # # lifeboats
end

You can use either of the two.


2022-09-21 18:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.