I want to catch an Postgres type mismatch exception (when provided function argument is not the type it should be by the arguments declaration) inside the function and rethrow it with my customized error response. How to obtain the described functionality? Maybe following exception is throwed by the function call and cannot be rethrowed. I tried to find the informations in Postgres documentation but without any result.
PostgreSQL: Type mismatch exception catch over function/procedure arguments
47 Views Asked by Adam Wróbel At
1
There are 1 best solutions below
Related Questions in POSTGRESQL
- Only the first SQL script gets executed inside Docker Postgres container
- Compare fields in two tables
- Hibernate ClobJdbcType bindings: what are the diferences?
- Postgres && statement Error in Mybatis Mapper?
- Can this query be optimized? (Choosing a random row to insert, that excludes previously inserted Rows)
- Connection terminated unexpectedly while performing multi row insert using pg-promise
- Processing multiple forms in nodejs and postgresql
- How to copy data from SQLite to postgreSQL?
- PGAdmin4 configured behind a reverse proxy but unable to connect to Postgresql server
- Updates to pgsodium encrypted values don't use specified key_id
- Connecting to Postgres running in a Docker container using psql
- Can't connect to local postgresql server from my docker container
- Django Arrayfield migration to cloud sql (Postgresql) not creating the column
- Get list of matching keywords for each post
- docker-compose can't reset postgresql database
Related Questions in EXCEPTION
- What should i use Exceptions or Monads for handle if service occur a problem?
- Python Requests: Handling Exceptions and Ensuring Server Response
- What is a better way to allow no user input while also preventing non-number inputs
- New error on random number assigned to local variable , Rails
- spring error exception with oauth2 and securityconfig
- Exception thrown: 'System.InvalidOperationException' in Microsoft.Data.SqlClient.dll
- How to fix this Row nested in Column exception issue in Flutter?
- GDI - Why the printing StartPage() function works in 32 bit but raises an exception in 64 bit?
- Handling Invalid Credential or Login error Exception in Python for Network Devices
- Execution failed for task ':app:compileFlutterBuildDebug'. > Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1Error:
- .NET 6 Custom Nuget package referencing other packages - Do I have to include the other packages myself?
- How to prevent Unity from catching and ignoring ALL exceptions
- My Google Apps Script renames all files in a folder from data in a spreadsheet. Can someone explain why it returns an exception error?
- Python (pylint): Catching general exceptions in validation procedures
- Need a simple example how to catch a data type error en C++
Related Questions in TRY-CATCH
- Capture and print entire exception and assertion error
- Promise.catch() does not work with firebase-admin Node.js SDK
- How can I execute a statement and ignore warnings with tryCatch?
- Can't create an exception "ApiError"
- Python: Try and Except usage to determine if a file path exists
- Why was try...catch was recommended to me here?
- My try catch error message is not showing up
- Try catch not catching error . mysqli / PHP
- new product get saved in the mongoose db but its shows that the product is not created
- Is there any perforamce implication of try catch block in node.js?
- Using tryCatch to avoid erros in a double loop
- How to check if a variable has been assigned a variable in AutoHotKey?
- Is a blank try and catch IndexOutOfBoundsException valid at the end of a while loop of if statements in C#?
- How can I ignore a case of a logical list throwing an error in R programming?
- PhpStorm Catch sentence with multiple exception classes PSR-12 code style
Related Questions in TYPE-MISMATCH
- VBA script to read values from one worksheet and write to another (set range problem)
- Data type mismatch in criteria expression for decimal with OleDbCommand
- How do I resolve a type 13 mismatch error when exporting data from Access to Excel?
- VBA: Type mismatch in dynamic range reference
- PostgreSQL: Type mismatch exception catch over function/procedure arguments
- Business Objects exports excel with extra line at the end, but opening excel to edit this results in type mismatch on zip and NAICS code
- Type Mismatch: cannot convert from Object to ObjectName
- The argument type 'List<dynamic>' can't be assigned to the parameter type 'List<SingleChildWidget>'
- Cannot match two identical types
- VBA issue between 2010 and 2016+
- How to pass Class.Companion as a parameter
- Type mismatch: inferred type is SectionPagerAdapter but RecyclerView.Adapter<(raw) RecyclerView.ViewHolder!>? was expected
- Any::hashCode function type mismatch
- New Scipy sparse.csgraph.connected_components error - ValueError: Buffer dtype mismatch
- VBA Excel Line throwing Error Code 13 Type Mismatch
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Overload it with polymorphic types and throw it there. It's not strictly catching and re-throwing, but since it'll only happen in the specific scenario where your exception would be thrown, it effectively does the same thing.
Here's PostgreSQL doc on function type resolution behaviour. Here's a demo at db<>fiddle:
Overloading the function with
variadic arg1 anycompatiblearraymakes it a catch-all for calls that didn't match any other variant.Still, that won't work with unknown literals:
And adding more overloads accepting specifically arguments of type
unknown, won't cut it:A workaround is to let the polymorphic catch-all be the only function under that name, wrapping calls to the other variants. That complicates the pass-through (you need to unpack the variadic and map it out to positional arguments) but thanks to the fact you effectively hijack any and all such calls, it also gives you more control over the order in which the db considers each function variant and how. This does catch and re-throw, so you'll have to catch the right one: