• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.format_error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.format_error函数的典型用法代码示例。如果您正苦于以下问题:Python format_error函数的具体用法?Python format_error怎么用?Python format_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了format_error函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: error_handler

    def error_handler(self, e, request, meth, em_format):
        """
        Override this method to add handling of errors customized for your
        needs
        """
        if isinstance(e, FormValidationError):
            return self.form_validation_response(e, self.determine_emitter(request))

        elif isinstance(e, TypeError):
            result = rc.BAD_REQUEST

            msg = "Method signature does not match.\n\n"

            try:
                hm = HandlerMethod(meth)
                sig = hm.signature

            except TypeError:
                msg += "Signature could not be determined"

            else:
                if sig:
                    msg += "Signature should be: %s" % sig
                else:
                    msg += "Resource does not expect any parameters."

            if self.display_errors:
                msg += "\n\nException was: %s" % str(e)

            result.content = format_error(msg)
            return result
        elif isinstance(e, Http404):
            return rc.NOT_FOUND

        elif isinstance(e, HttpStatusCode):
            return e.response

        else:
            """
            On errors (like code errors), we'd like to be able to
            give crash reports to both admins and also the calling
            user. There's two setting parameters for this:

            Parameters::
             - `PISTON_EMAIL_ERRORS`: Will send a Django formatted
               error email to people in `settings.ADMINS`.
             - `PISTON_DISPLAY_ERRORS`: Will return a simple traceback
               to the caller, so he can tell you what error they got.

            If `PISTON_DISPLAY_ERRORS` is not enabled, the caller will
            receive a basic "500 Internal Server Error" message.
            """
            exc_type, exc_value, tb = sys.exc_info()
            rep = ExceptionReporter(request, exc_type, exc_value, tb.tb_next)
            if self.email_errors:
                self.email_exception(rep)
            if self.display_errors:
                return HttpResponseServerError(format_error("\n".join(rep.format_exception())))
            else:
                raise
开发者ID:fern4lvarez,项目名称:django-piston,代码行数:60,代码来源:resource.py


示例2: msg

	def msg(self, to, *args):
		""" Sends a message to other nodes
		- to The identifier of the point of the ring that gets the
		message. Note that may or not be the same that the identifier of
		the node that manages that segment of the ring.
		- *args A list of arguments to pass to the other node ('the
		message'). Binary arguments must be wrapped in a xmlprclib.Binary
		object, and decoded in the destinity """	
		logger.info('%s: new application message'%self.id)
		if self.manage(to):
			# it is for me
			if not self.listener: return None
			try:
				return self.listener.message(to, *args)
			except:
				return "ERROR: "%utils.format_error()
		else:
			# it is not for me: inform to the listeners
			# and answers if there is a response
			r=None
			try:
				if self.listener:
					r=self.listener.routing(to, *args)
			except:
				logger.warn('Routing app: ' + utils.format_error())
			if r:
				return r
			else:
				return self.__next(to).msg(to, *args)
开发者ID:Juanvvc,项目名称:scfs,代码行数:29,代码来源:ring.py


示例3: __del__

	def __del__(self):
		""" Closes the file when there is no further reference """
		try:
			self.close()
		except:
			logger.warn('Error closing file %s'%self.uri.get_readable())
			utils.format_error()
开发者ID:Juanvvc,项目名称:scfs,代码行数:7,代码来源:filesystem.py


示例4: leave

	def leave(self):
		""" Leaves the network """
		try:
			logger.debug('%s: leaving the network'%self.id)
			if self.joined and self.next:
				na = self.contacted[self.next]
				if self.prev: self.__next(self.prev).leave_msg(self.id, self.next, na[0], na[1])
				if self.listener: self.listener.left(None)
				self.joined = False
				logger.info('%s: left the network'%self.id)
			else:
				logger.info('%s: I was alone in the network'%self.id)
		except:
			utils.format_error()
		self.server.shutdown()
开发者ID:Juanvvc,项目名称:scfs,代码行数:15,代码来源:ring.py


示例5: draw_toyMC

def draw_toyMC(hist,title,xlabel="",ylabel="",exponent=None, box="tl"):
    fit = root.TF1("gauss","gaus")
    textbox = r"\begin{align*}\mu&=%s\\\sigma&=%s\end{align*}"
    fig, a = utils.get_plotaxes((4,3.2))
    hist.Fit(fit,"LQ")
    r2mpl.plot(hist,axes=a, errors=True, color="k", zorder=1)
    r2mpl.plot(fit,axes=a, color="r", zorder=0)
    utils.text_box(a, box, textbox % (
        utils.format_error(fit.GetParameter(1), fit.GetParError(1), exponent=exponent),
        utils.format_error(fit.GetParameter(2), fit.GetParError(2), exponent=exponent)))

    a.set_title(title)
    a.set_xlabel(xlabel)
    a.set_ylabel(ylabel)
    return a, (fit.GetParameter(1), fit.GetParError(1)), (fit.GetParameter(2), fit.GetParError(2))
开发者ID:daritter,项目名称:OpenMPIFitter,代码行数:15,代码来源:toymc.py


示例6: calc_eff

def calc_eff(efficiency, errors, n=7, scale=1.0):
    total_eff=0
    total_err=0
    for i in range(n):
        for j in range(n):
            n1 = all_channels[i]
            n2 = all_channels[j]
            total_eff += br_Ds[n1] * br_Ds[n2] * br[n1] * br[n2] * efficiency[i,j]
            total_err += (br_Ds[n1] * br_Ds[n2] * br[n1] * br[n2] * errors[i,j])**2
    return utils.format_error(total_eff*scale,total_err**.5*scale,exponent=-5)
开发者ID:daritter,项目名称:OpenMPIFitter,代码行数:10,代码来源:efficiencies.py


示例7: message

	def message(self,to,*args):
		""" Receives a message from the ring """
		try:
			if args[0]=='GET':
				return self.__get(to,args[1])
			elif args[0]=='PUT':
				return self.__put(to,args[1],args[2])
			else:
				return 'No such method: %s'%args[0]
		except:
			return utils.format_error()
开发者ID:Juanvvc,项目名称:scfs,代码行数:11,代码来源:DHT.py


示例8: parse_options

def parse_options():
    _root = os.path.join(os.path.dirname(os.path.dirname(__file__)),"")
    _settings = os.path.join(_root, "settings.py")

    try:
        parse_config_file(_settings)
        logging.info("Using settings.py as default settings.")
        print "Using settings.py as default settings."
    except Exception as e:
        import traceback
        print (utils.format_error())
        logging.error("No any default settings, are you sure? Exception: %s" % e)

    parse_command_line()
开发者ID:niyoufa,项目名称:pyda,代码行数:14,代码来源:options.py


示例9: _complete_read

	def _complete_read(self):
		""" Reads the contents of the file."""
		s = []
		try:
			# read and return the whole file
			for p in self.parts:
				logger.info('Reading part ' + p)
				uri = uri_from_string(p)
				d = dfs.dht.get(uri.get_hd(),uri.nick)
				# TODO: do not decrypt now, but in the actual read
				if self.crypter:	d = self.crypter.decrypt(d)
				s.append(d)
			s=''.join(s)
			self.eof = True
			# TODO: check the file hashing before returning
			return s[0:self.filelength]
		except:
			raise IOError('Cannot read: %s'%utils.format_error())
开发者ID:Juanvvc,项目名称:scfs,代码行数:18,代码来源:filesystem.py


示例10: __next

	def __next(self,to):
		""" route a message to the point 'to' """
		try:
			if type(to)==tuple:
				p=xmlrpclib.ServerProxy("http://%s:%d"%to)
			else:
				# TODO: improve the routing. This one just circle the
				# message in the ring
				if self.contacted.has_key(to):
					na=self.contacted[to]
				else:
					na=self.contacted[self.next]	
				p=xmlrpclib.ServerProxy('http://%s:%d'%(na[0],na[1]))
			return p
		except:
			if type(to)==str:
				st=to
			else:
				st='%s:%d'%(to[0],to[1])
			logger.warn("%s: error routing message to %s"%(self.id,st))
			raise IOError(utils.format_error())
开发者ID:Juanvvc,项目名称:scfs,代码行数:21,代码来源:ring.py


示例11: error_handler

    def error_handler(self, e, request, meth, em_format):
        """
        Override this method to add handling of errors customized for your
        needs
        """
        if isinstance(e, FormValidationError):
            return self.form_validation_response(e)

        elif isinstance(e, Http404):
            return rc.NOT_FOUND

        elif isinstance(e, HttpStatusCode):
            return e.response

        else:
            """
            On errors (like code errors), we'd like to be able to
            give crash reports to both admins and also the calling
            user. There's two setting parameters for this:

            Parameters::
             - `PISTON_EMAIL_ERRORS`: Will send a Django formatted
               error email to people in `settings.ADMINS`.
             - `PISTON_DISPLAY_ERRORS`: Will return a simple traceback
               to the caller, so he can tell you what error they got.

            If `PISTON_DISPLAY_ERRORS` is not enabled, the caller will
            receive a basic "500 Internal Server Error" message.
            """

            exc_type, exc_value, tb = sys.exc_info()
            rep = ExceptionReporter(request, exc_type, exc_value, tb.tb_next)

            if self.email_errors:
                self.email_exception(rep)
            if self.display_errors:
                return HttpResponseServerError(
                    format_error('\n'.join(rep.format_exception())))
            else:
                raise
开发者ID:heroku,项目名称:django-piston,代码行数:40,代码来源:resource.py


示例12: f_Y

    ],
    "SVD2": [
        ("signal_corr_svd2_Mbc_mean",  "\Delta\mu(\mbc)"),
        ("signal_corr_svd2_Mbc_sigma", "\delta\sigma(\mbc)"),
        ("signal_corr_svd2_dE_mean",   "\Delta\mu(\de)"),
        ("signal_corr_svd2_dE_sigma",  "\delta\sigma(\de)"),
        ("signal_corr_svd2_rbin1",     "\delta f_Y(rbin0)"),
        ("signal_corr_svd2_rbin2",     "\delta f_Y(rbin1)"),
        ("signal_corr_svd2_rbin3",     "\delta f_Y(rbin2)"),
        ("signal_corr_svd2_rbin4",     "\delta f_Y(rbin3)"),
        ("signal_corr_svd2_rbin5",     "\delta f_Y(rbin4)"),
        ("signal_corr_svd2_rbin6",     "\delta f_Y(rbin5)"),
    ]
}

params = dspdsmks.Parameters()
params.load(sys.argv[1])


for svd, names in sorted(fields.items()):
    print r"""\begin{tabular}{LRCL}
    \toprule
    Name&Value\\
    \midrule"""
    for p,t in names:
        print r"    {0} & {1}\\" .format(t, utils.format_error(params(p).value, params(p).error, align=True))
    print r"""    \bottomrule
\end{tabular}"""


开发者ID:daritter,项目名称:OpenMPIFitter,代码行数:28,代码来源:print_corr.py


示例13: run_jobs

    cpv_result = [jc_result, js1_result, js2_result, bl_result, bbar_svd1_result, bbar_svd2_result]
    cpv_pull = [root.TH1D(e.GetName()+"_pull","",100,-5,5) for e in cpv_result]
    cpv_params = ["signal_dt_Jc", "signal_dt_Js1", "signal_dt_Js2", "signal_dt_blifetime", "yield_bbar_svd1", "yield_bbar_svd2"]
    cpv_input = [params(e).value for e in cpv_params]

    for parfile in run_jobs(False, True):
        if not os.path.exists(parfile): continue
        params.load(parfile)
        br = params("yield_signal_br").value
        br_error = params("yield_signal_br").error
        br_result.Fill(br)
        br_pull.Fill((br-utils.br)/br_error)

        for i,p in enumerate([params(e) for e in cpv_params]):
            cpv_result[i].Fill(p.value)
            cpv_pull[i].Fill((p.value-cpv_input[i])/p.error)

    a,m,s = draw_toyMC(br_result, r"fit results, input=$%s$" % utils.format_error(utils.br, precision=1), "$\mathcal{B}(\ddk)$", exponent=-3, ylabel=r"Entries / \num{%s}" % br_result.GetBinWidth(1))
    a.set_ylim(0, br_result.GetMaximum()*1.5)
    draw_toyMC(br_pull,"pull distribution", xlabel=r"Pull($\mathcal{B}(\ddk)$)", ylabel="Entries / %s" % br_pull.GetBinWidth(1))

    names = [r"$J_C/J_0$", r"$(2J_{s1}/J_0) \sin(2\phi_1)$", r"$(2J_{s2}/J_0) \cos(2\phi_1)$",r"$\tau / ps$","m1","m2"]

    for i,name in enumerate(names):
        hist = cpv_result[i]
        pull = cpv_pull[i]
        draw_toyMC(hist, r"fit results, input=$%.3g$" % cpv_input[i], xlabel=name, ylabel="Entries / %s" % hist.GetBinWidth(1))
        draw_toyMC(pull, r"pull distribution", xlabel="Pull(%s)" % name, ylabel="Entries / %s" % pull.GetBinWidth(1))

    r2mpl.save_all("toymc/toymc-%s" % toyname, png=False, single_pdf=True)
开发者ID:daritter,项目名称:OpenMPIFitter,代码行数:30,代码来源:toymc.py


示例14: HandlerMethod

        except TypeError, e:
            result = rc.BAD_REQUEST
            hm = HandlerMethod(meth)
            sig = hm.get_signature()

            msg = 'Method signature does not match.\n\n'
            
            if sig:
                msg += 'Signature should be: %s' % sig
            else:
                msg += 'Resource does not expect any parameters.'

            if self.display_errors:                
                msg += '\n\nException was: %s' % str(e)
                
            result.content = format_error(msg)
        except HttpStatusCode, e:
            #result = e ## why is this being passed on and not just dealt with now?
            return e.response
        except Exception, e:
            """
            On errors (like code errors), we'd like to be able to
            give crash reports to both admins and also the calling
            user. There's two setting parameters for this:
            
            Parameters::
             - `PISTON_EMAIL_ERRORS`: Will send a Django formatted
               error email to people in `settings.ADMINS`.
             - `PISTON_DISPLAY_ERRORS`: Will return a simple traceback
               to the caller, so he can tell you what error they got.
               
开发者ID:egon0,项目名称:Adlibre-DMS,代码行数:30,代码来源:resource.py


示例15: ExceptionReporter

        error email to people in `settings.ADMINS`.
      - `FULCRUM_DISPLAY_ERRORS`: Will return a simple traceback
        to the caller, so he can tell you what error they got.
        
     If `FULCRUM_DISPLAY_ERRORS` is not enabled, the caller will
     receive a basic "500 Internal Server Error" message.
     """
     
     exc_type, exc_value, tb = sys.exc_info()
     rep = ExceptionReporter(request, exc_type, exc_value, tb.tb_next)
     
     if self.email_errors:
         self.email_exception(rep)
     if self.display_errors:
         return HttpResponseServerError(
             format_error('\n'.join(rep.format_exception())))
     else:
         raise
 
 # Return serialized data
 emitter, ct = Emitter.get(em_format)
 srl = emitter(result, recurse_level, typemapper, handler, handler.fields, anonymous)
 
 try:
     """
     Decide whether or not we want a generator here,
     or we just want to buffer up the entire result
     before sending it to the client. Won't matter for
     smaller datasets, but larger will have an impact.
     """
     if self.stream: stream = srl.stream_render(request)
开发者ID:octothorp,项目名称:django-fulcrum,代码行数:31,代码来源:resource.py


示例16:

print r"""
\def\BMultiplicity{%.1f}
\def\FractionCorrectRec{\SI{%.1f}{\%%}}
\def\FractionCorrectBestB{\SI{%.1f}{\%%}}
\def\ReconstructedBR{\num{%.3e}}
\def\RawReconstructionEffSVDOne{%s}
\def\RawReconstructionEffSVDTwo{%s}
\def\ReconstructionEffSVDOne{%s}
\def\ReconstructionEffSVDTwo{%s}
\def\ReconstructionEffSVDOneCorr{%s}
\def\ReconstructionEffSVDTwoCorr{%s}""" % (
    b_mult,
    100*ncorrect[1] / (ncorrect[0]+ncorrect[1]),
    100*bestB[1] / (bestB[0]+bestB[1]),
    eff_DDKs,
    utils.format_error(*raw_eff[0], exponent=-3),
    utils.format_error(*raw_eff[1], exponent=-3),
    utils.format_error(*rec_eff[0], exponent=-5),
    utils.format_error(*rec_eff[1], exponent=-5),
    utils.format_error(*rec_eff_c[0], exponent=-5),
    utils.format_error(*rec_eff_c[1], exponent=-5),
)

print r"""
\def\BMultiplicityCtrl{%.1f}
\def\FractionCorrectRecCtrl{\SI{%.1f}{\%%}}
\def\FractionCorrectBestBCtrl{\SI{%.1f}{\%%}}
\def\ReconstructedBRCtrl{\num{%.3e}}
\def\RawReconstructionEffSVDOneCtrl{%s}
\def\RawReconstructionEffSVDTwoCtrl{%s}
\def\ReconstructionEffSVDOneCtrl{%s}
开发者ID:daritter,项目名称:OpenMPIFitter,代码行数:31,代码来源:print_pars.py


示例17: __init__

	def __init__(self,uri,mode,config=None,save_metadata=True,keys=None):
		""" Initializes the file object.
		- uri is a URI or str object with the address of the file.
		- mode is the mode of the file. Currently, just 'w' and 'r'
		- keys are a pair (Kf, Kd) to use. If None, use the pair in the
		configuration. Kf is used to crypt/decrypt the file and Kd to
		secure the resource localization
		- config is the configuration to use. In None, use the default 
		configuration
		- keys is an array of identifiers for the keys used in the file: in None,
		it uses KEY_NAMES (see extended documentation)
		- If save_metadata is True, the file descriptor is saved in
		the DHT. You can access to the file descriptor with
		File.metadata """
		
		if not config: config=dfs.default_config
		self.config=config
		if not keys: keys=KEY_NAMES
		self.keys=[]
		for k in keys:
			self.keys.append(self.config.get_key(k))

		if type(uri)==str: uri=uri_from_string(uri,config=config,kd=self.keys[0])

		logger.debug("Accesing file %s (%s)"%(uri, mode))
		
		self.uri=uri
		self.mode = mode
		self.closed = True
		
		self.buffer=[]
		# The maximum block size
		self.BLOCK_SIZE=self.config.getint('File:block',dfs.dht.BLOCK_SIZE)
		# The file descriptor could be bigger than the block size. To
		# prevent this, the metadata is chained in several blocks
		# Use this parameter to control how many part references
		# a block of metadata holds.
		self.DESC_PER_METAPART=self.config.getint('File:descPerMetapart',12)
		# The max length of the internal buffer before an automatic flush()
		self.MAX_BUFFER=self.config.getint('File:maxbuffer',4096)
		self.save_metadata=save_metadata
		
		if mode=='r':
			# crypter used to decrypt the metadata. There is always
			# a crypter to protect against casual atackers, but
			# if there is no Kff the crypter is nearly useless
			if SECURED:
				if self.keys and self.keys[0]:
					mdencrypter=AES.new(self.keys[4],AES.MODE_CBC,self.uri.get_hd())
				else:
					mdencrypter=AES.new(self.uri.get_hd(),AES.MODE_CBC,self.uri.get_hd())
			else:
				mdencrypter=DummyEncrypter()
			# get the metadata from the DHT
			md=dfs.dht.get(uri.get_hd(),uri.nick)
			if not md: raise IOError('No reference to that file: ' + uri.get_static())
			self.metadata=utils.Config()
			md=mdencrypter.decrypt(md)
			try:
				self.metadata.load(md)
			except:
				raise IOError('The reference is not metatada: %s'%utils.format_error())
			# get basic information from the metadata
			self.uri.uid=self.metadata.get('Main:UID')
			self.uri.nick=self.metadata.get('Main:nick')
			np=self.metadata.getint('Main:parts', 0)
			self.filelength=self.metadata.getint('Main:length')
			# get info about each one of the parts
			self.parts=[]
			cmd=self.metadata
			for next_part in range(0,np):
				self.parts.append(cmd.get("Part:%d"%next_part))
				# load chained metadata
				if next_part<np-1 and next_part%self.DESC_PER_METAPART==self.DESC_PER_METAPART-1:
					nuri=uri_from_string(cmd.get('Main:n'))
					md=dfs.dht.get(nuri.get_hd(),nuri.nick)
					if not md: raise IOError('No reference to %s (%d)'%(nuri.get_static(),next_part))
					md=mdencrypter.decrypt(md)
					cmd=utils.Config()
					try:
						cmd.load(md)
					except:
						raise IOError('The reference is not metadata: %s'%utils.format_error())
					
			self.eof=bool(len(self.parts)==0)
		elif mode=='w':
			if not self.uri.uid: self.uri.uid=dfs.default_config.get('Main:UID')
			if not self.uri.nick:
				self.uri.nick=dfs.default_config.get('Main:nick')
				#if not self.uri.nick: self.uri.nick=utils.random_nick()
			self.metadata=utils.Config()
			self.metadata.set('Main:UID',self.uri.uid)
			if self.uri.nick:
				self.metadata.set('Main:nick',self.uri.nick)
			self.parts=[]
			self.filelength=0
		else:
			raise IOError,'Mode not supported: %s'%mode
		
		s='File %s in mode "%s" '%(self.uri.get_readable(),self.mode)
#.........这里部分代码省略.........
开发者ID:Juanvvc,项目名称:scfs,代码行数:101,代码来源:filesystem.py


示例18: in

            lin_result.SetBinError(x,fit.GetParError(1))
            one_pull.Fit(fit,"LQ")
            lin_pull_mean.SetBinContent(x,fit.GetParameter(1))
            lin_pull_mean.SetBinError(x,fit.GetParError(1))
            lin_pull_sigma.SetBinContent(x,fit.GetParameter(2))
            lin_pull_sigma.SetBinError(x,fit.GetParError(2))

        fit = root.TF1("line","pol1",-0.8,0.8)
        for a,h in (a1,lin_result),(a2,lin_pull_mean),(a3,lin_pull_sigma):
            if par is not "yield_signal_br":
                h.Fit(fit,"Q")
            else:
                h.Fit(fit,"Q")
            r2mpl.plot(h, axes=a, errors=True, color=colors[par])
            r2mpl.plot(fit, axes=a, color=colors[par])
            utils.text_box(a, "tl", r"\begin{align*}m&=%s\\t&=%s\end{align*}" % (utils.format_error(fit.GetParameter(1), fit.GetParError(1)), utils.format_error(fit.GetParameter(0), fit.GetParError(0))))

        lin_res = lin_result.Clone("tmp")
        for i in range(1,lin_res.GetNbinsX()+1):
            lin_res.SetBinContent(i,lin_res.GetBinContent(i)-lin_res.GetBinCenter(i))
        r2mpl.plot(lin_res, axes=a1, errors=True, color="k")

        if par is not "yield_signal_br":
            #ymin = result.GetYaxis().GetXmin()
            #ymax = result.GetYaxis().GetXmax()
            a1.set_ylim(-1.2,1.2)
        a2.set_ylim(-1,1)
        a3.set_ylim(0,2)

    elif isinstance(result,root.TH1D):
        toymc.draw_toyMC(result,title)
开发者ID:daritter,项目名称:OpenMPIFitter,代码行数:31,代码来源:plot_linearity_full.py


示例19: error_handler

    def error_handler(self, response, e, request, meth):
        """
        Override this method to add handling of errors customized for your
        needs
        """
        response.status_code = 500
        if isinstance(e, (PistonException, PistonBadRequestException, PistonForbiddenException, PistonMethodException, PistonNotFoundException, PistonUnauthorizedException)):
            response.status_code = e.status_code
            response.error_message = e.message
            response.headers.update(e.headers)
        elif isinstance(e, FormValidationError):
            response.status_code = 400
            response.form_errors = e.form.errors
        elif isinstance(e, TypeError) and meth:
            hm = HandlerMethod(meth)
            sig = hm.signature

            msg = 'Method signature does not match.\n\n'

            if sig:
                msg += 'Signature should be: %s' % sig
            else:
                msg += 'Resource does not expect any parameters.'

            if self.display_errors:
                msg += '\n\nException was: %s' % str(e)

            response.error_message = format_error(msg)
        # TODO: As we start using Piston exceptions, the following 2 errors can be phased out
        elif isinstance(e, Http404):
            response.status_code = 404
            response.error_message = 'Not Found'
        elif isinstance(e, HttpStatusCode):
            response.error_message = e.response
        else:
            """
            On errors (like code errors), we'd like to be able to
            give crash reports to both admins and also the calling
            user. There's two setting parameters for this:

            Parameters::
             - `PISTON_EMAIL_ERRORS`: Will send a Django formatted
               error email to people in `settings.ADMINS`.
             - `PISTON_DISPLAY_ERRORS`: Will return a simple message/full traceback
               depending on `PISTON_DISPLAY_TRACEBACK`. Default is simple message
               to the caller, so he can tell you what error they got.

            If `PISTON_DISPLAY_ERRORS` is not enabled, the caller will
            receive a basic "500 Internal Server Error" message.
            """
            exc_type, exc_value, tb = sys.exc_info()
            rep = ExceptionReporter(request, exc_type, exc_value, tb.tb_next)
            if self.email_errors:
                self.email_exception(rep)
            if self.display_errors:
                if self.display_traceback:
                    response.error_message = format_error('\n'.join(rep.format_exception()))
                else:
                    response.error_message = str(e)
            else:
                raise
开发者ID:Artemists,项目名称:verese,代码行数:61,代码来源:resource.py



注:本文中的utils.format_error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.fread函数代码示例发布时间:2022-05-26
下一篇:
Python utils.float2str函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap