Current behavior :
Here's a small example of exceptions not being handled in classes.
class MyClass {
throwError() {
throw new Error("test");
}
getError() {
this.throwError();
try {
this.throwError();
} catch {
throw new Error("test");
}
}
async throwErrorAsync() {
throw new Error("test");
}
async getErrorAsync() {
await this.throwErrorAsync();
try {
await this.throwErrorAsync();
} catch {
throw new Error("test");
}
}
}
const myClass = new MyClass();
myClass.getError();
myClass.getErrorAsync();
No error is pointed out.
Expected behavior :
- Both
throw new Error("test"); lines should warn about use-error-cause.
myClass.getError(); and myClass.getErrorAsync(); should warn about might-throw and no-unhandled.
this.throwError(); should warn about might-throw when not in a try statement.
Remarks:
try {
} catch (err) {
throw new Error("test");
}
will warn about use-error-cause but the following will not :
try {
throwError();
} catch {
throw new Error("test");
}
However, the former is not rethrowing, when the latter is.
Current behavior :
Here's a small example of exceptions not being handled in classes.
No error is pointed out.
Expected behavior :
throw new Error("test");lines should warn aboutuse-error-cause.myClass.getError();andmyClass.getErrorAsync();should warn aboutmight-throwandno-unhandled.this.throwError();should warn aboutmight-throwwhen not in atrystatement.Remarks:
will warn about
use-error-causebut the following will not :However, the former is not rethrowing, when the latter is.