Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common exception class #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions lib/cmis/exceptions.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
module CMIS
module Exceptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of the exceptions module, it just adds complexity.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not, as this will surely break backwards compatibility with certain clients of this lib that rely on rescuing these exceptions.

Also, by removing the Exceptions namespace, assuming we still want to enforce a common parent class for all CMIS service related exceptions/errors, we would have to write CMIS::StorageException iso CMIS::Exceptions::Storage, which to me, is the same thing.

If you feel that strongly about removing the Exceptions namespace a compromise would be to introduce a new exception parent for each exception that sits between ServiceError and the exception.

For example

module CMIS
  ServiceError = Class.new(StandardError)
  StorageException = Class.new(ServiceError)
  module Exceptions
    Storage = Class.new(StorageException)
    ...

InvalidArgument = Class.new(StandardError)
Copy link
Contributor

@bertBruynooghe bertBruynooghe Nov 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about ordering them alpabetically? Would make things more maintainable...

NotSupported = Class.new(StandardError)
ObjectNotFound = Class.new(StandardError)
PermissionDenied = Class.new(StandardError)
Runtime = Class.new(StandardError)
Constraint = Class.new(StandardError)
ContentAlreadyExists = Class.new(StandardError)
FilterNotValid = Class.new(StandardError)
NameConstraintViolation = Class.new(StandardError)
Storage = Class.new(StandardError)
StreamNotSupported = Class.new(StandardError)
UpdateConflict = Class.new(StandardError)
Versioning = Class.new(StandardError)
ServiceError = Class.new(StandardError)
InvalidArgument = Class.new(ServiceError)
NotSupported = Class.new(ServiceError)
ObjectNotFound = Class.new(ServiceError)
PermissionDenied = Class.new(ServiceError)
Runtime = Class.new(ServiceError)
Constraint = Class.new(ServiceError)
ContentAlreadyExists = Class.new(ServiceError)
FilterNotValid = Class.new(ServiceError)
NameConstraintViolation = Class.new(ServiceError)
Storage = Class.new(ServiceError)
StreamNotSupported = Class.new(ServiceError)
UpdateConflict = Class.new(ServiceError)
Versioning = Class.new(ServiceError)

# Non-CMIS
Unauthorized = Class.new(StandardError)
Expand Down