Skip to content

' Signal

Signal an error


where x is a symbol atom or string, aborts evaluation and passes x to the interpreter as a string.


Signal is part of q syntax. It is not an operator and cannot be iterated or projected.

' Quote overloads

The only way to detect a signal is to use Trap.


Trap always receives a string regardless of the type of x.


q)f 1         / signals a type error indicating ' will not signal a number
q)f"a"        /q will not signal a char

Using an undefined word signals the word as an error:


which is indistinguishable from


Error-trap modes

At any point during execution, the behavior of signal (') is determined by the internal error-trap mode:

0 abort execution (set by Trap or Trap At) 1 suspend execution and run the debugger 2 collect stack trace and abort (set by .Q.trp)

During abort, the stack is unwound up to the nearest trap (@ or . or .Q.trp). The error-trap mode is always initially set to

1  for console input
0  for sync message processing

\e sets the mode applied before async and HTTP callbacks run. Thus, \e 1 will cause the relevant handlers to break into the debugger, while \e 2 will dump the backtrace either to the server console (for async), or into the socket (for HTTP).

q)\e 2
q)'type             / incoming async msg signals 'type
  [2]  f@:{x*y}
  [1]  f:{{x*y}[x;3#x]}
  [0]  f `a
q)\e 1
  [2]  f@:{x*y}
q))                 / the server is suspended in a debug session

Trap, Trap At
Controlling evaluation, Debugging, Error handling
Q for Mortals §10.1.7 Return and Signal

Back to top