GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing it.javascript.info — Eredita da SyntaxError

  • Tutorial
  • Il linguaggio JavaScript
  • Gestione degli errori
  • Errori personalizzati, estendere la classe Error
torna alle lezioni

Eredita da SyntaxError

importanza: 5

Crea una classe FormatError che eredita dalla classe incorporata SyntaxError.

Dovrebbe supportare le proprietà message, name e stack.

Esempio di esecuzione:

let err = new FormatError("formatting error");

alert( err.message ); // Errore nella formattazione
alert( err.name ); // FormatError
alert( err.stack ); // stack

alert( err instanceof FormatError ); // vero
alert( err instanceof SyntaxError ); // vero (poiché eredita SyntaxError)
class FormatError extends SyntaxError {
  constructor(message) {
    super(message);
    this.name = this.constructor.name;
  }
}

let err = new FormatError("errore di formattazione");

alert( err.message ); // errore di formattazione
alert( err.name ); // FormatError
alert( err.stack ); // stack

alert( err instanceof SyntaxError ); // vero
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.