clkao / plv8js-migrated

Automatically exported from code.google.com/p/plv8js
Other
0 stars 0 forks source link

Add support for FATAL errors: plv8.elog(FATAL, "You broke it"); #72

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. plv8.elog(FATAL, "You broke it");

What is the expected output?
Trigger a FATAL error in PostgreSQL terminating the current session.

What do you see instead?
"ERROR:  ReferenceError: FATAL is not defined"

What version of the product are you using? On what operating system?
1.4.1

Please provide any additional information below.
I would like to be able to trigger a FATAL error, not just ERROR. To maintain 
ACID transactions, I'd like to trigger ERRORs for expected use cases like a 
record not found on an update.  If a null pointer/undefined errors happens, I'd 
like my try/catch to trigger a FATAL error. Both will roll a transaction back, 
but having them separate allows me to handle expected errors one way and 
unexpected errors another.

Attached patch will fix this by adding FATAL support in this code:
http://code.google.com/p/plv8js/source/browse/plv8.cc#1352
http://code.google.com/p/plv8js/source/browse/plv8_func.cc#312

Original issue reported on code.google.com by ben...@gmail.com on 23 May 2013 at 9:57

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch.  Though, I don't think we should support FATAL in a 
trusted language.  FATAL generally means the process cannot proceed at all and 
kill the process itself, but in javascript it is never the case.  If you need 
to differentiate the types of error, throwing different object is the way, I 
believe.

Original comment by umi.tan...@gmail.com on 24 May 2013 at 6:08

GoogleCodeExporter commented 9 years ago
Thanks for the feedback.  I've found a workaround using custom error types that 
meets my needs.

You can close this issue.

Original comment by ben...@gmail.com on 24 May 2013 at 10:10

GoogleCodeExporter commented 9 years ago

Original comment by umi.tan...@gmail.com on 24 May 2013 at 11:15