I think that "Not implemented" is common enough to warrant a dedicated exception class.
Details
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Commits
- rPHUefc2cc5c7728: Add a `PhutilMethodNotImplementedException` class
[2014-07-21 14:33:42] EXCEPTION: (PhutilMethodNotImplementedException) Method testMethod in class TestClass is not implemented! at [<phutil>/test.php:7] #0 TestClass::testMethod() called at [<phutil>/test.php:11] [2014-07-21 14:33:14] EXCEPTION: (PhutilMethodNotImplementedException) Function foo is not implemented! at [<phutil>/test.php:13] #0 foo() called at [<phutil>/test.php:15]
Diff Detail
Diff Detail
- Repository
- rPHU libphutil
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
Comment Actions
- Let's pseudo-namespace this (PhutilNotImplementedException)? It seems likely that it might collide with third-party code.
- It might be nice to debug_backtrace() and reach into the calling frame to construct a default error message ("method X in class Y is not implemented"). Maybe it should be PhutilMethodNotImplementedException to set up an expectation that it's called from a method body and can reasonably expect to interpret the call stack like that? Although it could probably figure things out reasonably well.
Comment Actions
- Rename to PhutilMethodNotImplementedException
- Throw a better default exception message
Comment Actions
Like this?
[2014-07-21 14:33:42] EXCEPTION: (PhutilMethodNotImplementedException) Method testMethod in class TestClass is not implemented! at [<phutil>/test.php:7] #0 TestClass::testMethod() called at [<phutil>/test.php:11] [2014-07-21 14:33:14] EXCEPTION: (PhutilMethodNotImplementedException) Function foo is not implemented! at [<phutil>/test.php:13] #0 foo() called at [<phutil>/test.php:15]
Comment Actions
Hmm, since the stack trace already provides the class/method I wonder if there's any point in trying to provide a detailed error message.
Comment Actions
There are common cases where the stack trace is not shown:
- arc without --trace
- web UI with developer mode off.
Users are also slightly better ("bad") at reporting error messages than stack traces ("very bad").