Error handling strategy for service requests

interface ErrorHandlerConfig {
    strategy: "throw" | "log" | "ignore" | "default";
    defaultValue?: any;
    onError?: ((error, model) => void);
}

Properties

strategy: "throw" | "log" | "ignore" | "default"

How to handle errors

  • 'throw': Re-throw error (default)
  • 'log': Log error and continue
  • 'ignore': Silently ignore errors
  • 'default': Return default value
defaultValue?: any

Default value to return when strategy is 'default'

onError?: ((error, model) => void)

Custom error handler function

Type declaration

    • (error, model): void
    • Parameters

      • error: Error
      • model: IKosDataModel

      Returns void