Skip to content

Add throwable to php try/catch block snippet#60012

Merged
roblourens merged 3 commits intomicrosoft:masterfrom
benjamenjohnsondev:master
Oct 9, 2018
Merged

Add throwable to php try/catch block snippet#60012
roblourens merged 3 commits intomicrosoft:masterfrom
benjamenjohnsondev:master

Conversation

@benjamenjohnsondev
Copy link
Contributor

Add Throwable to try catch block snippet as requested:
3edd274#r30777567

@benjamenjohnsondev benjamenjohnsondev changed the title Add throwable to try/catch block Add throwable to php try/catch block snippet Oct 5, 2018
Copy link
Contributor

@oneslash oneslash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since throwable is higher interface, next catch of exception will not be reached

@oneslash
Copy link
Contributor

oneslash commented Oct 5, 2018

code should look like

try {
} catch(\Throwable $th) {
}

or

try {
} catch(\Exception $ex) {
} catch(\Error $err) {
}

Personally, I prefer first one

@benjamenjohnsondev
Copy link
Contributor Author

Unreachable exception removed - user editable catch parameter added, this should cover most use cases - thanks for your help @oneslash

"\t${1://code...}",
"} catch (\\Exception \\$$e) {",
"\t${2://throw $$e;}",
"} catch (${2:\\Throwable} ${3:$$t}) {",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be $th?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Changed 1de8905

Copy link
Member

@roblourens roblourens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@roblourens roblourens merged commit 46b7914 into microsoft:master Oct 9, 2018
@roblourens roblourens added this to the October 2018 milestone Oct 9, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants