Add truncate command while generalizing error code