/**
 * Workflow error classes
 * Errors specific to workflow execution
 */

import { ExecutionError } from '../base/errors'

/**
 * Thrown when a workflow step fails during execution
 *
 * Severity: error (step failure — errors always take precedence over warnings)
 * Category: workflow
 *
 * @example
 * ```typescript
 * throw new WorkflowStepError(
 *   'Step "send_email" failed: SMTP server unavailable',
 *   {
 *     workflowId: 'wf-123',
 *     stepIndex: 2,
 *     stepName: 'send_email',
 *     attemptCount: 1
 *   }
 * )
 * ```
 */
export class WorkflowStepError extends ExecutionError {
  readonly type = 'workflow_step_error' as const
  readonly severity = 'critical' as const
  readonly category = 'workflow' as const

  constructor(message: string, context?: Record<string, unknown>) {
    super(message, context)
  }
}

/**
 * Thrown when workflow validation fails
 *
 * Severity: info (validation failure indicating user/developer configuration error)
 * Category: validation
 *
 * @example
 * ```typescript
 * throw new WorkflowValidationError(
 *   'Invalid workflow: Step "approval" has no approver configured',
 *   {
 *     workflowId: 'wf-123',
 *     stepIndex: 3,
 *     field: 'approver'
 *   }
 * )
 * ```
 */
export class WorkflowValidationError extends ExecutionError {
  readonly type = 'workflow_validation_error' as const
  readonly severity = 'info' as const
  readonly category = 'validation' as const

  constructor(message: string, context?: Record<string, unknown>) {
    super(message, context)
  }
}
