Asyncredux user exceptions

From marcglasberg/async_redux · View interactive version

Asyncredux user exceptions is an AI agent skill from the GitHub repository marcglasberg/async_redux. Create actionable user-facing AsyncRedux errors and display or test them through the error queue.

How to use this skill

Skill file

Report user-facing failures

Throw a UserException from before or reduce for a failure the user can act on.

Let unexpected failures reach the normal error reporting path. Attach the underlying

cause with addCause when translating a known error. Place UserExceptionDialog<AppState>

inside the app near the navigator for default dialogs, or supply

onShowUserExceptionDialog for a custom presentation.

For an inline-only failure, use ifOpenDialog: false and render it with

context.isFailed and context.exceptionFor. A dialog-eligible exception enters the

store's error queue and is consumed by the dialog widget. The queue and the remembered

failure for an action serve different UI behavior.

class SetCounter extends AppAction {
  SetCounter(this.value);
  final int value;

  @override
  AppState reduce() {
    if (value < 0) {
      throw const UserException('Enter a count of zero or more.', ifOpenDialog: false);
    }
    return state.copy(counter: value);
  }
}

This reducer uses the setup skill's base action and state. In tests, await

dispatchAndWait and assert the failure plus the type and message of

status.wrappedError. Check store.errors separately when testing dialog eligibility.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.