modify method exceptions are not catched
See original GitHub issueHi,
Exceptions in modify
method are not catched by .catch
knex.select()
.from('Account')
.modify(function(qb) {
throw new Error('ERROR HERE');
})
.then(r => {})
.catch(err => console.log('Catched Error:', err));
// Throws: ERROR HERE
On the other hand
knex.select()
.from('Account')
.where(function() {
throw new Error('ERROR HERE');
})
.then(r => {})
.catch(err => console.log('Catched Error:', err));
// Throws: Catched Error: ERROR HERE
Regards,
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
How can you add use a method that throws an exception ...
Sometimes when the JDK declares a method, e.g. Integer.parseInt(String s) it throws a NumberFormatException , yet when the method is called you ...
Read more >Best Practices for exceptions - .NET - Microsoft Learn
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >Specifying the Exceptions Thrown by a Method
If the writeList method doesn't catch the checked exceptions that can occur within it, the writeList method must specify that it can throw...
Read more >Exceptions and Error Handling, C++ FAQ - Standard C++
But MFC seems to encourage the use of catch-by-pointer; should I do the same? ... Do not use exceptions as simply another way...
Read more >9 Best Practices to Handle Java Exceptions - Stackify
If you use Throwable in a catch clause, it will not only catch all exceptions; it will also catch all errors. Errors are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@elhigu Your second version could be even nicer by just using
Promise.try
(when using bluebird):@elhigu, I mean, I could not find a workaround without adding further nested code, otherwise second workaround is totally acceptable, and I already applied second one in a couple of places. However for another larger project I have, I wish I had small number of modify methods.
@johanneslumpe, also nice suggestions.
Thanks both of you guys for your helps and suggestions.