js api Error Function and Boolean