# trapping system

**URL:** https://forum.kx.com/t/trapping-system/8094
**Category:** Community Support
**Tags:** kdb-and-q
**Created:** [January 9, 2013, 6:54am UTC](https://forum.kx.com/t/trapping-system/8094 "2013-01-09T06:54:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jack31](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jack31](https://forum.kx.com/u/jack31)
#### Post date: [January 9, 2013, 6:54am UTC](https://forum.kx.com/t/trapping-system/8094/1 "2013-01-09T06:54:00Z")

</div>

this is a funny one… the q expression dumps me into k… and it’s a type 101h - unary primitive

KDB+ 3.0 2012.11.13 Copyright (C) 1993-2012 Kx Systems  
l32/ 2()core 3539MB jack localhost.localdomain 127.0.0.1 PLAY 2013.02.11

q)type system “l nofile” 42  
? \   
q)type system “l nofile” 42  
101h  
? \   
q)

i’m trying to get ? @[system;“l 42”;0] ? to work.? i want to catch the error so i can print it - ie.  
? '42: No such file or directory

can i get the error?

ta, jack

---

<div class="post-metadata">

### Author: ![jayhan](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@jayhan](https://forum.kx.com/u/jayhan)
#### Post date: [January 9, 2013, 7:27am UTC](https://forum.kx.com/t/trapping-system/8094/2 "2013-01-09T07:27:00Z")

</div>

how about

q)\l nofile

k){if[$[1\>@d:!f:-1!x;1;`.d~*d];:.[$[qt d;*|`:f;`.];();:;d:. f]];d@:&~d like"*$";p:(d=`par.txt)|d like"[0-9]\*";

&nbsp;."\cd “,$x;f .q.set’{$[0h\>@!x:-1!x;. x;x`]}'f:d@&~(d=`html)|p|s:”.“in’$d;if[|/p;L d@&p];if[~`.=x;(.”\l ",$:)'d@&s&~p];}

'nofile: No such file or directory

.:

`:nofile

q.Q))

q.Q))\

q)@[system; “l nofile”; ::]

“nofile: No such file or directory”

q)error:@[system; “l nofile”; ::]

q)type error

10h

q)error

“nofile: No such file or directory”

q)

---

<div class="post-metadata">

### Author: ![abcfoots1](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@abcfoots1](https://forum.kx.com/u/abcfoots1)
#### Post date: [January 9, 2013, 12:56pm UTC](https://forum.kx.com/t/trapping-system/8094/3 "2013-01-09T12:56:00Z")

</div>

q)@[system;“l 42”;{x}]  
“42: No such file or directory”

Also good to return success/fail

q)res:@[{(0b;system)};“l 42”;{(1b;x)}]  
q)if[res[0];-1 res[1]]  
42: No such file or directory
