KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have 3 classes: Error ShellError WebError where ShellError extends Error and WebError extends Error In ShellError there are fields some of which are optional and others are required. I am building the object in the following manner: shellError = new ShellError.Builder().setFile(filePattern) .setHost(host).setPath(path).setSource(file.isSource()) .setJobName(p.getJobName()).build(); Since ShellError extends Error , I further: shellError.setDescription(msg.toString()); shellError.setExceptionClass("MyEvilException"); shellError.setExceptionMessage("Some clever error message"); shellError.setStacktrace(stack); So ... why bother with Builder? I like the fact that my build() amongst other things conveniently validates that all fields are set appropriately etc. I would love it if I could .. build() ShellError and add to it the fields from the Error class. What i did works. The question is: Is there a better way, or does it make sense what I did? -- EDIT I updated Builder() to accept some of the parameters which were in Error class before. Now I have shellError = new ShellError.Builder(exception, "Some description").setFile(filePattern).setHost(host) .setPath(path).setSource(file.isSource()). setJobName(p.getJobName()).build(); What do you say? Better? Worse?
Tags (comma-separated)
Save Edits
Cancel