Skip to content

@vaguevoid/fiasco / error / error

Function: error()

error(name, msg): void

Defined in: src/error.ts:22

error creates an error with a name and message the name can be used to identify the error type in a try/catch

Parameters

name

string

name to tag the error with

msg

string

the message to display

Returns

void

Example

ts
try {
 throw error('InvalidArgument', 'foo is not a valid argument');
} catch(err) {
  if (err.name == 'InvalidArgument') {
    console.log(err.message) // foo is not a valid argument
  }
  throw err;
}