Skip to content

Error: ENOENT, No such file or directory when db doesn't already exist. #16

@jed

Description

@jed

Currently, dirty throws an error when called with a file that does not exist. It still creates the file, though, so that subsequent attempts are successful.

Example:

var Dirty = require( "dirty" )
  , path = require( "path" )
  , real = "real.db"
  , imaginary = "imaginary.db"

require( "fs" ).writeFileSync( real, "" )

process.on( "uncaughtException", function( err ) {
  console.log( "Caught exception: " + err )
});

path.exists( real, function( exists ) {
  console.log( real + " exists? " + exists )
})

path.exists( imaginary, function( exists ) {
  console.log( imaginary + " exists? " + exists )
})

Dirty( "real.db" )
Dirty( "imaginary.db" )

path.exists( real, function( exists ) {
  console.log( real + " exists? " + exists )
})

path.exists( imaginary, function( exists ) {
  console.log( imaginary + " exists? " + exists )
})

which outputs:

$ node dirty.js 
real.db exists? true
imaginary.db exists? false
Caught exception: Error: ENOENT, No such file or directory 'imaginary.db'
real.db exists? true
imaginary.db exists? true

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions