中文
← Errors

F_SYSTEM_UNKNOWN_HANDLER

Unknown registered Handler

A registered Command lacks role metadata, or a Provider declares an @Handler method.

Updated

Reproduction

An ordinary Provider cannot declare @Handler methods:

src/app.module.ts
import { Handler, Injectable, Module, createApp } from 'func'

@Injectable()
class ProjectService {
  @Handler()
  run() {}
}

@Module({ providers: [ProjectService] })
class AppModule {}

createApp(AppModule)

What this error means

Only a Command or @OptionCommand class may own @Handler methods. When a Handler is found on an ordinary Provider, details.host identifies the class and details.handlers lists its method names.

Putting a class with no func role decorator in Module.commands raises the same error; in that case, details.handlers lists the unclassified Command classes. A subclass does not inherit the Command role. Even if it inherits a decorated Handler method, it must declare its own Command decorator.

How to fix it

Add @Command(), @CommandMajor(), or @CommandMissing() to every registered Command class. If the class is a reusable dependency, decorate it with @Injectable(), move it to Module.providers, and remove @Handler. Inject the Provider through a constructor or Handler parameter when an action needs its capability.