c# - Exception handling - Exception within a catch clause? -
i downloading data text files db tables. data in files corrupt @ field level (files comma delimited .csv files)
i reading each line object represents data line properties correct datatype.
if read object fails due dodgy data, want read line similar object first one, 1 has data types set string read should not fal.
the idea being can create collection of valid record objects load in appropriate db table, , collection of exceptions load exceptions table. these can dealt later.
so - question: going loop through lines of text file , load these object , add object collection. there try/catch loop around , if object load fails, in catch section load exception object , add collection of exceptions.
however, happens if exception object load fails (for whatever reason). put try/catch around , log exceptions - i.e try/catch within try/catch?
is there better way of doing this?
- code within
catchblock no way different other code.
so have protect every critical action try catch otherwise program might crash.
2. might personal flavor, not recommend use try control flow - use if instead. use if-statements detect dodgy data.
Comments
Post a Comment