Sha256: 2de2e89d93dc47bdcdcde27428193e263f1e3fc1fe9d283fe81bbc41b36b6036

Contents?: true

Size: 1.15 KB

Versions: 26

Compression:

Stored size: 1.15 KB

Contents

import { format } from 'outvariant'

const LIBRARY_PREFIX = '[MSW]'

/**
 * Formats a given message by appending the library's prefix string.
 */
function formatMessage(message: string, ...positionals: any[]): string {
  const interpolatedMessage = format(message, ...positionals)
  return `${LIBRARY_PREFIX} ${interpolatedMessage}`
}

/**
 * Prints a library-specific warning.
 */
function warn(message: string, ...positionals: any[]): void {
  // eslint-disable-next-line no-console
  console.warn(formatMessage(message, ...positionals))
}

/**
 * Prints a library-specific error.
 */
function error(message: string, ...positionals: any[]): void {
  // eslint-disable-next-line no-console
  console.error(formatMessage(message, ...positionals))
}

export const devUtils = {
  formatMessage,
  warn,
  error,
}

/**
 * Internal error instance.
 * Used to differentiate the library errors that must be forwarded
 * to the user from the unhandled exceptions. Use this if you don't
 * wish for the error to be coerced to a 500 fallback response.
 */
export class InternalError extends Error {
  constructor(message: string) {
    super(message)
    this.name = 'InternalError'
  }
}

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.25 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.24 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.23 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.22 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.21 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.20 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.19 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.18 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.17 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.16 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.15 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.14 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.13 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.12 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.11 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.10 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.9 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.8 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts
clapton-0.0.7 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/devUtils.ts