New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Flag to ignore common 409 conflicts #2720

Closed
moander opened this Issue Nov 3, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@moander

moander commented Nov 3, 2017

If functions like pubsub SubscriberClient#createSubscriptions had a flag to ignore 409 ALREADY_EXISTS it would be possible to write code like this:

try {
    await client.createTopic(..);
    
    await client.createSubscription(..);    
}
catch (err) {
    console.log(err)
}

Instead of this

try {
    try {
        await client.createTopic(..);
    } 
    catch(err) {
        if (err.code !== 409) {
            throw err;
        }
    }

    try {
        await client.createSubscription(..);
    } 
    catch(err) {
        if (err.code !== 409) {
            throw err;
        }
    }
}
catch (err) {
    console.log(err)
}
@stephenplusplus

This comment has been minimized.

Show comment
Hide comment
@moander

This comment has been minimized.

Show comment
Hide comment
@moander

moander Nov 3, 2017

Thank you :)

const topic =  pubsub.topic('foo');
await topic.get({autoCreate:true});

const sub = topic.subscription('bar');
await sub.get({autoCreate:true});        

moander commented Nov 3, 2017

Thank you :)

const topic =  pubsub.topic('foo');
await topic.get({autoCreate:true});

const sub = topic.subscription('bar');
await sub.get({autoCreate:true});        
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment