2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-28 11:57:37 +00:00

Create particular exceptions and start using them

This commit is contained in:
Jarrod Johnson 2013-11-02 17:32:48 -04:00
parent cf7ffe9de2
commit 4eaaa0c1a9
4 changed files with 10 additions and 4 deletions

View File

@ -46,7 +46,6 @@ from Crypto.Hash import SHA256
import array
import ast
import collections
import confluent.config.crypto as crypto
import confluent.util
import copy
import cPickle

5
confluent/exceptions.py Normal file
View File

@ -0,0 +1,5 @@
class ConfluentException(Exception):
pass
class NotFoundException(ConfluentException):
pass

View File

@ -7,6 +7,7 @@ import base64
import Cookie
import confluent.auth as auth
import confluent.consoleserver as consoleserver
import confluent.exceptions as exc
import confluent.pluginapi as pluginapi
import confluent.util as util
import eventlet
@ -192,13 +193,13 @@ def resourcehandler(env, start_response):
yield rsp
return
else:
start_response('200 OK', headers)
try:
hdlr = pluginapi.handle_path(env['PATH_INFO'], 'retrieve', cfgmgr)
except:
except exc.NotFoundException:
start_response('404 Not found', headers)
yield "404 - Request path not recognized"
return
start_response('200 OK', headers)
for rsp in hdlr:
yield rsp.json()

View File

@ -18,6 +18,7 @@
# see API.txt
import confluent.interface.console as console
import confluent.exceptions as exc
import os
import sys
@ -106,7 +107,7 @@ def handle_path(path, operation, configmanager):
else:
return stripnode(passvalue, node)
else:
raise Exception("TODO: notfoundexception")
raise exc.NotFoundException()