Skip to main content

ee

Function ee 

Source
pub unsafe extern "C" fn ee(result: K) -> K
Expand description

Capture (and reset) error string into usual error object.

ยงExample

use kdbplus::qtype;
use kdbplus::api::*;
use kdbplus::api::native::*;

extern "C" fn catchy(func: K, args: K) -> K{
  unsafe{
    let result=ee(dot(func, args));
    if (*result).qtype == qtype::ERROR{
      println!("error: {}", S_to_str((*result).value.symbol));
      // Decrement reference count of the error object
      r0(result);
      KNULL
    }
    else{
      result
    }
  }
}
q)catchy: `libc_api_examples 2: (`catchy; 2);
q)catchy[$; ("J"; "42")]
42
q)catchy[+; (1; `a)]
error: type