fluentfixture
ContributionCode of Conduct
  • Fluent Fixture
  • PACKAGES
    • @fluentfixture/core
      • Everything Is A Factory
      • Streams
        • Stream
        • Boolean Stream
        • Number Stream
        • String Stream
        • Date Stream
        • Array Stream
        • Object Stream
      • Generators
      • Live Demo
    • @fluentfixture/format
      • Structure
      • Pipe Functions
        • Built-In Pipes
        • Custom Pipes
      • How To Use
      • Error Handling
      • Live Demo
  • 🫂Contribution
  • 🐦Follow me on Twitter :)
Powered by GitBook
On this page
  • Syntax Errors
  • Pipe Errors
Edit on GitHub
  1. PACKAGES
  2. @fluentfixture/format

Error Handling

In the formatting process, there may be two types of errors.

  • Syntax errors.

  • Pipe errors.

Syntax Errors

Syntax errors are always thrown. The following templates are invalid.

import { format } from '@fluentfixture/format';

format('${name:}', {}); // missing transformers.
format('${name:padStart}', {}); // missing parameters.
format('${padStart()}', {}); // missing semicolon at the index 0.
format("${:split(',')}", {}); // single quotes are not supported.

Pipe Errors

Pipe errors occur while invoking a pipe function. By default, these kinds of errors are handled by the library.

With IgnoreErrors Flag (Default)

import { Formatter, Pipes } from '@fluentfixture/format';

const formatter = Formatter.create(Pipes.withDefaults(), { ignoreErrors: true });

formatter.format('ITEMS = ${items:join("+")}', { });
// ITEMS = 

Without IgnoreErrors Flag

import { Formatter, Pipes } from '@fluentfixture/format';

const formatter = Formatter.create(Pipes.withDefaults(), { ignoreErrors: false });

formatter.format('ITEMS = ${items:join("+")}', { });
// TypeError: Cannot read properties of undefined (reading 'join')
PreviousHow To Use

Last updated 7 months ago