[question] why this is only related to vue?
k1r0s opened this issue · comments
why this appears to work only in vue rather than every ES6 class?
@k1r0s Thank you! I fixed title. The description left after another library. Since the first idea was to create a decorator for Vue using createDecorator
method from vue-class-component. I use Vue components for examples only (as use case) and highlighted this in the first sentanse under "How to use?" section, but catch-decorator works with any ES/Typescript classes :)
Why you depend on
├─┬ catch-decorator@1.0.3
│ ├── vue@2.5.17
│ └── vue-class-component@6.2.0
It doens't work with static methods on ES6 classes
(node:17270) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'constructor' of undefined
at runHandler (/home/k1r0s/Development/test-decorators/node_modules/catch-decorator/dist/index.js:84:80)
at Function.<anonymous> (/home/k1r0s/Development/test-decorators/node_modules/catch-decorator/dist/index.js:111:36)
at Generator.throw (<anonymous>)
at rejected (/home/k1r0s/Development/test-decorators/node_modules/catch-decorator/dist/index.js:49:69)
at <anonymous>
at runMicrotasksCallback (internal/process/next_tick.js:121:5)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:695:11)
at Object.<anonymous> (/home/k1r0s/Development/test-decorators/node_modules/@babel/node/lib/_babel-node.js:221:23)
(node:17270) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:17270) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@k1r0s My mistake, I'll remove this dependencies (as I wrote, this are traces left from the previous lib).
Can you, please, create new issue related to static methods on ES6 classes?
I came across this repo bcoz you own https://www.npmjs.com/package/catch-decorator :))) and I have suggestions regarding on this repo
I can provide something that works everywhere and can be stacked:
@Throws(SyntaxError, "your expression is malformed")
@Throws(TypeError, "another message")
method() {
asds() // bcoz this is a ReferenceError, exception isn't catched
}
and
@Throws(SyntaxError, "your expression is malformed")
@Throws(TypeError, "another message")
method() {
mm1mm1m1,,1 // SyntaxError is throwed so its handled and "your expression is malformed" is returned
}
But I would like to publish under catch-decorator
on npm. I can make a PR
@k1r0s Good idea :) Feel free to open pull request with your description. There are many more nuances that can be implemented.
good luck