I'm new to the SOLID principles. I have this scenario:
class ErrorClass {
constructor(name: string, description: string) {
//
}
}
class Class1 {
public someMethod() {
try {
// good scenario
} catch (error) {
throw new ErrorClass("Error Name","Error Description");
}
}
}
Is that wrong? Am I allowed to call ErrorClass
directly from Class1
or am I supposed to inject ErrorClass
into Class1
as a dependency? I'm worried that my Class1
constructor can get bloated if I have to inject different error classes along with other classes it might also depend on?
Grateful for any help or advice!
Thanks