{"record":{"id":"cc361397a1ab8bcb","repo":"chinabugotech/hutool","slug":"no-tasks-run-can-t-get-last-task-info","errorCode":null,"errorMessage":"No tasks run: can't get last task info","messagePattern":"No tasks run: can't get last task info","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hutool-core/src/main/java/cn/hutool/core/date/StopWatch.java","lineNumber":251,"sourceCode":"\t * @return 任务名\n\t * @throws IllegalStateException 无任务\n\t */\n\tpublic String getLastTaskName() throws IllegalStateException {\n\t\tif (this.lastTaskInfo == null) {\n\t\t\tthrow new IllegalStateException(\"No tasks run: can't get last task name\");\n\t\t}\n\t\treturn this.lastTaskInfo.getTaskName();\n\t}\n\n\t/**\n\t * 获取最后的任务对象\n\t *\n\t * @return {@link TaskInfo} 任务对象，包括任务名和花费时间\n\t * @throws IllegalStateException 无任务\n\t */\n\tpublic TaskInfo getLastTaskInfo() throws IllegalStateException {\n\t\tif (this.lastTaskInfo == null) {\n\t\t\tthrow new IllegalStateException(\"No tasks run: can't get last task info\");\n\t\t}\n\t\treturn this.lastTaskInfo;\n\t}\n\n\t/**\n\t * 获取所有任务的总花费时间\n\t *\n\t * @param unit 时间单位，{@code null}表示默认{@link TimeUnit#NANOSECONDS}\n\t * @return 花费时间\n\t * @since 5.7.16\n\t */\n\tpublic long getTotal(TimeUnit unit){\n\t\treturn unit.convert(this.totalTimeNanos, TimeUnit.NANOSECONDS);\n\t}\n\n\t/**\n\t * 获取所有任务的总花费时间（纳秒）\n\t *","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-core/src/main/java/cn/hutool/core/date/StopWatch.java#L233-L269","documentation":"Error \"No tasks run: can't get last task info\" thrown in chinabugotech/hutool.","triggerScenarios":"Thrown at hutool-core/src/main/java/cn/hutool/core/date/StopWatch.java:251 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run at least one task before requesting the last task info.","Check getTaskCount() > 0 before calling getLastTaskInfo()."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}