Code Lab

Mode entretien. Minuteur de 4 min, sans indices ni autocomplétion

Your own error

FacileErrors4 min

Write a class FormatError for errors in a data format. It extends the built-in SyntaxError. For new FormatError('bad date') the message field is 'bad date' and the name field is 'FormatError'.

Exemples

new FormatError('bad date').message

Renvoie 'bad date'

new FormatError('bad date').name

Renvoie 'FormatError'

new FormatError('bad date') instanceof SyntaxError

Renvoie true

Source

Chargement de l'éditeur...
  1. message comes from the constructor, name is FormatError
  2. The error is a FormatError, a SyntaxError and an Error

Les tests cachés se lancent à la soumission