Custom exceptions

Open
#77 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
data

Research direction

Start by reviewing the existing DeprecationError in mixin.netcdf and the candidate exception categories listed in this issue. Before implementing anything, narrow the scope and decide which implementation, metadata, data, field-operation, and encoding errors belong in the hierarchy and how completion will be verified.

Written by the indexing model from the issue text.

Description

enhancement

cfdm does not use any custom exceptions, other than DeprecationError in mixin.netcdf. We could likely make some classes a bit cleaner & improve user feedback on errors etc. by creating & applying some custom exception classes for which to delegate some error handling.

(Copied, minus noise & with a little tidying, from https://github.com/NCAS-CMS/cfdm/issues/64#issuecomment-689170011)

Ideas

I can flesh this out further e.g. with some potential inheritance structure as we think about it & work out what might be useful, but firstly to record some potential candidates for useful exceptions:

  • cfdm implementation errors (relating to attempts to subclass);
  • CF compliance warnings (as specific forms of Python warnings lib warnings that the user can opt to enable or disable by interfacing with the logging framework);
  • construct i.e. metadata errors:
    • missing i.e. not defined when expected/required;
    • mismatched dimensions or shape;
    • invalid;
    • etc.
  • data errors, e.g perhaps:
    • array-related;
    • compression-related;
  • field construct operation errors:
    • on reading fields;
    • on writing fields;
    • on aggregation;
  • errors related to a specific encoding, notably netCDF.
Dominant language
Python
Stars
32
Forks
14
Avg merge
3d 20h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NCAS-CMS/cfdm

All issues in NCAS-CMS/cfdm

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.