chinabugotech/hutool · error · IllegalStateException

No tasks run: can't get last task name

Error message

No tasks run: can't get last task name

What it means

Error "No tasks run: can't get last task name" thrown in chinabugotech/hutool.

Source

Thrown at hutool-core/src/main/java/cn/hutool/core/date/StopWatch.java:238

	 * @return 任务的花费时间(毫秒)
	 * @throws IllegalStateException 无任务
	 */
	public long getLastTaskTimeMillis() throws IllegalStateException {
		if (this.lastTaskInfo == null) {
			throw new IllegalStateException("No tasks run: can't get last task interval");
		}
		return this.lastTaskInfo.getTimeMillis();
	}

	/**
	 * 获取最后的任务名
	 *
	 * @return 任务名
	 * @throws IllegalStateException 无任务
	 */
	public String getLastTaskName() throws IllegalStateException {
		if (this.lastTaskInfo == null) {
			throw new IllegalStateException("No tasks run: can't get last task name");
		}
		return this.lastTaskInfo.getTaskName();
	}

	/**
	 * 获取最后的任务对象
	 *
	 * @return {@link TaskInfo} 任务对象,包括任务名和花费时间
	 * @throws IllegalStateException 无任务
	 */
	public TaskInfo getLastTaskInfo() throws IllegalStateException {
		if (this.lastTaskInfo == null) {
			throw new IllegalStateException("No tasks run: can't get last task info");
		}
		return this.lastTaskInfo;
	}

	/**

View on GitHub (pinned to 8870454b2a)

Solutions

  1. Run at least one task before requesting the last task name.
  2. Check getTaskCount() > 0 before calling getLastTaskName().

When it happens

Trigger: Thrown at hutool-core/src/main/java/cn/hutool/core/date/StopWatch.java:238 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of chinabugotech/hutool@8870454b2a (2026-08-14). Data as JSON: /api/errors/77b45d22b79a32a2. Report an issue: GitHub.