Skip to content

Request: Default template string #28

Description

@cableray

It would be nice to call an error like so:

class CustomError extends SError {
  static defaultTemplate =  'there was a problem with foo: {foo}'
}

error = CustomError.create({foo: 'bar'})
// => error.message = 'there was a problem with foo: bar'

Having the message template defined with the error seems to separate responsibilities better: the error message knows how to display the error, and the call-site does not need to know that. Seems to me to better design in some cases, by moving more logic to the error object and away from the call-site.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions