Error handling. How should a program do it? - language-agnostic

How should a program handle errors? Example:
A program needs the file text.txt. It must exist and be writable. What should it do if it's not writable or doesn't exist? Should it try to chown/chmod the file? Should it try to create it or just display an error message?
Or: Should it try to find a solution or just display an error message?

It's up to you how to handle it. You have to define your scenarios, user interactions, and other parts of the program. Once you define those it is time to implement and test those scenarios.
Some questions to ask:
What data is being written to the file?
How critical is it that the data get saved?
If an error is reported, who will see the error?
If an error is reported, how do you expect a user to react? And what are their options?

I would go with Eilon's answer for the most part but would add the following caveat - I would not try to chown/chmod a file, unless you really need to i.e. if the purpose of your program is managing file permissions or acting as an installer of some sort. This is because a) your attempted chmod/chown may not work and b) your application should respect the user privileges with which it is run - if these are not sufficient you should inform the user via whatever mechanism you do this.

Your program should output an error on STDERR and return with an exit code different than zero.
For more informations :
http://en.wikipedia.org/wiki/Exit_status

Related

There was an error while loading the package SSIS

I have created one SSIS package for data flow and its perfectly working fine for me (with my credentials). However, when its opened by another person with another login ID (credentials) its showing error:
Please see the below screenshot.Looks like its an access error. How can I give access so that anyone can open it.
The error I'm getting is :
the operation failed because the databse manager failed to access either the databse manager configuration file or the database configuration file.
There ware errors while loading the package. See the error list for details.
Error loading Package.dtsx. Failed to decrypt protected XML node "DTS:Password" with error 0x8009000B "Key not valid for use in specified satte. You may not be
authorized to access this information. This occurs when there is a cryptographic error. Verify that the correct key is available.
Upon searching on net. I think I can set "DontSaveSensitive". However,unable to find out how to do this? Whats are the steps I need to follow?
Link : https://learn.microsoft.com/en-us/sql/integration-services/security/access-control-for-sensitive-data-in-packages
How to resolve this?
Kudos for pinpointing issue. To solve it:
Open project solution from working credentials.
Right click on project.
Go to properties
Change the security level to DontSaveSensitive.
I've answered your question about unable to find out how to do this
Hope this works. Else come back here and we might suggest different approach.

Cloudconnect CSV buffer size

When I try to load a big CSV from a zip file, the execution log give me the following error:
----------------------------------------- Error details ------------------------------------------
Component [Clientes:CLIENTES1] finished with status ERROR.
The size of data buffer is only 100663296. Set appropriate parameter in defaultProperties file.
--------------------------------------------------------------------------------------------------
How can I set the appropriate parameter in defaultProperties file?
I tried this link, but my cloudconnect run configurations page is different from the link:
I've created the parameters file and filled the additional parameters with the right values like said the tutorial (code bellow) and the same error appear in the screen.
Name: -config; Value: new_buffer_size.txt
The new_buffer_size.txt content have just this line:DEFAULT_INTERNAL_IO_BUFFER_SIZE = 200000000
How can I solve this problem? I need to solve this before the world explodes.
CloudConnect is designed to develop ETL(s), which can be run on GoodData cloud workers and therefore some lower level settings are surpassed as in this case. The only legitimate way is to modify the ETL the way it can process the data with current settings. Regarding to docs, the referenced article is outdated. GoodData docs team is aware if it and they are preparing docs refactoring.
Note: As you have probably noticed, CloudConnect is being powered by Javlin's Clover ETL, therefore feel free to check their forums, as you would find there how to overcome the issue on lower level (no UI), but it would work only for data processing on the local machine.

SGE error can't open output file

I'm trying to run PsN with run_on_sge but keep getting this error when I submit multiple runs simultaneously. I'm also getting "error: can't chdir to directory".
I suspect the PsN scripts may not be creating the run directories before submitting the job but am not certain. I'm also a little unsure of how to test this.
The nodes have access to the NFS mounted directories in question and the permissions look fine. Any pointers appreciated!!
Note to self: don't mess up the UID's when creating user accounts on the compute nodes.
UID's did not match between (3) compute nodes and the head node... which resulted in 'intermitted' failures with the error mentioned. Whenever a job was submitted to a UID mismatched node the job failed with what now seems to be a pretty obvious error message.

Not able to make calls to mod_roster_odbc functions

I tried to use my own custom roster by integrating mod_roster_odbc. I changed the config file too (commented out mod_roster and make a new entry for mod_roster_odbc). After running with this setup, mod_roster_odbc module is getting started ( I put some logs to in start function, those I can see). But none of other function is not getting called as I alter presence or logged out/logged in.
Please help to identify where I am making the mistake.
I think I know the answer to this. many websites tell you to use mod_roster_odbc.erl to create your own rostering. I believe thats your problem. Many of the functions are merged into mod_roster.erl file itself. I dont think this is mentioned anywhere.
So what you need to do is in ejabberd.cfg enable mod_roster_odbc but dont remove the mod_roster.erl file with the odbc file. This file will take care.
Finally you need to create a rosterusers table (or something like it) so that ejabber can query for friend list. After these changes, just restart ejabber server and you should be good to go. hope this helps.

SSIS package Error

i have updated the old SSIS Load package. i have changed the variable names and some other stuff but when i try to execute package it gives me error for old variable names that variable not found. now i checked it so many times, i have no old variable name defined anywhere then why its giving me error for previous variable names?
Thanks
Hard to diagnose your issue without any error messages or detail, but you could view the xml (think it's View menu, then Code), and search the XML text for any instances of the old variable that is throwing the error.
Best guess is that you are referencing the old variable name in an expression somewhere. If you are allowed in your environment, download BIDS Helper. It will highlight expressions for you to make them easier to find and correct.