-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't rethrow a type error #50498
base: master
Are you sure you want to change the base?
Don't rethrow a type error #50498
Conversation
Signed-off-by: Daniel Kesselberg <[email protected]>
80f053a
to
5ddc520
Compare
try { | ||
$this->emit('exception', [$e]); | ||
} catch (\Exception $ignore) { | ||
$e = new TypeError('A type error occurred. For more details, please refer to the logs, which provide additional context about the type error.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$e = new TypeError('A type error occurred. For more details, please refer to the logs, which provide additional context about the type error.'); | |
$e = new TypeError('A type error occurred. For more details, please refer to the logs, which provide additional context about the type error.', 0, $e); |
Would it be a problem to store the previous exception? It seems it’s only part of the response in debug mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question 👍
The debugExceptions blocks appear to be dead code because there's no code in server setting it to true. Sounds like a nice enhancement to also include a stack trace, when debug enabled, for dav requests.
For non-dav requests we already include the stack trace with debug true.
if ($e instanceof \TypeError) { | ||
try { | ||
$this->emit('exception', [$e]); | ||
} catch (\Exception $ignore) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} catch (\Exception $ignore) { | |
} catch (\Exception) { |
Follow-up for #49004
Alternative to #49960
Summary
Rethrowing may trigger a weird code path in remote.php1 and therefore it's better to replace the type error with a generic one. The actual expection is still logged.
Test cases for manual testing:
TODO
Checklist
Footnotes
https://github.com/nextcloud/server/blob/2c773033bcf44268cad1e427fffdb9bbcc6a0327/remote.php#L27-L29 ↩