Sha256: e02fc29c08122cc42b293ed4c0ba83de55156c358fdb36617c5fbf868e861e43
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
# coding: utf-8 require 'json' module COS # 异常基类 class Exception < RuntimeError; end # 服务端返回异常 # Code: -166, Message: 索引不存在, HttpCode: 400 # Code: -173, Message: 目录非空, HttpCode: 400 # Code: -180, Message: 非法路径, HttpCode: 400 # Code: -288, Message: process打包失败, HttpCode: 400 # Code: -4018, Message: 相同文件已上传过, HttpCode: 400 # Code: -5997, Message: 后端网络错误, HttpCode: 400 # Code: -5999, Message: 参数错误, HttpCode: 400 class ServerError < Exception attr_reader :response, :http_code, :error_code, :message def initialize(response) @response = response resp_obj = JSON.parse(response.body) @error_code = resp_obj['code'] @message = resp_obj['message'] @http_code = response.code end def message @message || "UnknownError[#{http_code}]." end def to_s "ServerError Code: #{error_code}, Message: #{message}, HttpCode: #{http_code}" end end # 参数错误 class AttrError < Exception; end # 客户端错误 class ClientError < Exception; end # 文件不一致 class FileInconsistentError < Exception; end # 断点续传记录损坏 class CheckpointBrokenError < Exception; end # 下载错误 class DownloadError < Exception; end # 文件上传未完成 class FileUploadNotComplete < Exception; end # 本地目录不存在 class LocalPathNotExist < Exception; end # 完整上传文件过大 class EntireUploadTooLarge < Exception; end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cos-0.1.2 | lib/cos/exception.rb |