2

I have such namespace with errors

errorMessages=
  error404Find: "Hosts not found"
  error404FindByHost: "Host - #{hostName} - not found"
  error400: "No host"

hostName should be assigned to null and overrided in function like:

this.hostName = 'smth'

or can I use something like in python:

errorMessages=
  {'error404Find': "Hosts not found"
  'error404FindByHost': "Host - {hostName} - not found"
  'error400': "No host"}
errorMessages['error404FindByHost'].format(hostName='smth')

1 Answer 1

1

You can make all those entries a functions, then apply a dictionary to them with arguments:

errorMessages=
  error404Find:-> "Hosts not found"
  error404FindByHost:-> "Host - #{@hostName} - not found"
  error400:-> "No host"

alert errorMessages["error404FindByHost"].apply hostName:"host1"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.