Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file pb_exception.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287(*
The MIT License (MIT)
Copyright (c) 2016 Maxime Ransan <maxime.ransan@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*)(** {2 Compilation errors } *)moduleP=PrintfmoduleLoc=Pb_locationtypeprogrammatic_error=|Invalid_string_split|No_type_found_for_idletstring_of_programmatic_errore="Programatic_error"^matchewith|Invalid_string_split->"string split error"|No_type_found_for_id->"no type was found for type id"typeunresolved_type={field_name:string;type_:string;message_name:string;}typeduplicate_field_number={field_name:string;previous_field_name:string;message_name:string;}typeinvalid_default_value={field_name:stringoption;info:string;}typeunsupported_field_type={field_name:stringoption;field_type:string;backend_name:string;}typeerror=|Unresolved_typeofunresolved_type(* When the type of a field could not be resolved *)|Duplicated_field_numberofduplicate_field_number(* When there are 2 field with either identical number or name *)|Invalid_default_valueofinvalid_default_value(* When a default value type type does not match the field type *)|Unsupported_field_typeofunsupported_field_type|Programatic_errorofprogrammatic_error|Invalid_import_qualifierofLoc.t|Invalid_file_nameofstring|Import_file_not_foundofstring|Invalid_packed_optionofstring|Missing_semicolon_for_enum_valueofstring*Loc.t|Invalid_enum_specificationofstring*Loc.t|Invalid_mutable_optionofstringoption|Missing_one_of_nameofLoc.t|Missing_field_labelofstring*string|Parsing_errorof{msg:string;context:string;loc:Loc.t;}|Invalid_ppx_extension_optionofstring|Invalid_protobuf_syntaxofstring|Invalid_proto3_field_labelofstring*string|Default_field_option_not_supportedofstring*string|Invalid_first_enum_value_proto3ofstring*stringoption|Invalid_key_type_for_mapofstring|Unsupported_wrapper_typeofstring|Invalid_rpc_req_typeofstring*string|Invalid_rpc_res_typeofstring*stringexceptionCompilation_erroroferror(** Exception raised when a compilation error occurs *)letstring_of_error=function|Unresolved_type{field_name;type_;message_name}->P.sprintf"unresolved type for field name : %s (type:%s, in message: %s)"field_nametype_message_name|Duplicated_field_number{field_name;previous_field_name;message_name}->P.sprintf"duplicated field number for field name: %s (previous field name:%s, \
message: %s)"field_nameprevious_field_namemessage_name|Invalid_default_value{field_name;info}->P.sprintf"invalid default value for field name:%s (info: %s)"(Pb_util.Option.default""field_name)info|Unsupported_field_type{field_name;field_type;backend_name}->P.sprintf"unsupported field type for field name:%s with type:%s in bakend: %s"(Pb_util.Option.default""field_name)field_typebackend_name|Programatic_errore->P.sprintf"programmatic error: %s"(string_of_programmatic_errore)|Invalid_import_qualifierloc->P.sprintf"%sInvalid import qualified, only 'public' supported"(Loc.to_stringloc)|Invalid_file_namefile_name->P.sprintf("Invalid file name: %s, "^^"format must <name>.proto")file_name|Import_file_not_foundfile_name->P.sprintf("File: %s, "^^"could not be found.")file_name|Invalid_packed_optionfield_name->P.sprintf"Invalid packed option for field: %s"field_name|Missing_semicolon_for_enum_value(enum_value,loc)->P.sprintf"%sMissing semicolon for enum value: %s"(Loc.to_stringloc)enum_value|Missing_one_of_nameloc->P.sprintf"%sMissing oneof name"(Loc.to_stringloc)|Missing_field_label(field_name,message_name)->P.sprintf("Missing field label for field: %s in message: %s. "^^"[required|repeated|optional] expected")field_namemessage_name|Parsing_error{msg;context;loc}->Printf.sprintf"%s%s at `%s'."(Loc.to_stringloc)msgcontext|Invalid_enum_specification(enum_name,loc)->P.sprintf"%sMissing enum specification (<identifier> = <id>;) for enum value: %s"(Loc.to_stringloc)enum_name|Invalid_mutable_optionfield_name->P.sprintf"Invalid mutable option for field %s"(Pb_util.Option.default""field_name)|Invalid_ppx_extension_optionmessage_name->P.sprintf"Invalid ppx extension value for message: %s, string expected"message_name|Invalid_protobuf_syntaxsyntax->P.sprintf"Invalid protobuf syntax: \"%s\", expected \"proto2\" or \"proto3\""syntax|Invalid_proto3_field_label(field_name,message_name)->P.sprintf("Invalid field label for field: %s in message: %s. "^^"[Required|Optional] are not supported.")field_namemessage_name|Invalid_rpc_req_type(service_name,rpc_name)->P.sprintf("Invalid type for RPC request: %s in service: %s. "^^"The type must be user-defined..")service_namerpc_name|Invalid_rpc_res_type(service_name,rpc_name)->P.sprintf("Invalid type for RPC response: %s in service: %s. "^^"The type must be user-defined..")service_namerpc_name|Default_field_option_not_supported(field_name,message_name)->P.sprintf("Explicit default values are not allowed in proto3. "^^"field name: %s, message name: %s.")field_namemessage_name|Invalid_first_enum_value_proto3(enum_name,message_name)->P.sprintf("The first enum value must be 0 in proto3."^^"enum name: %s, message name: %s.")enum_name(Pb_util.Option.string_of_option(funx->x)message_name)|Invalid_key_type_for_mapfield_name->P.sprintf("Invalid key type for field %s. Map key type only supports integral "^^"and string type")field_name|Unsupported_wrapper_typetype_name->P.sprintf"Unsupported wrapper type %s, please raise issue on github."type_namelet()=Printexc.register_printer(funexn->matchexnwith|Compilation_errore->Some(string_of_errore)|_->None)letunresolved_type~field_name~type_~message_name()=raise(Compilation_error(Unresolved_type{field_name;type_;message_name}))letduplicated_field_number~field_name~previous_field_name~message_name()=raise(Compilation_error(Duplicated_field_number{field_name;previous_field_name;message_name}))letinvalid_default_value?field_name~info()=raise(Compilation_error(Invalid_default_value{field_name;info}))letunsupported_field_type?field_name~field_type~backend_name()=raise(Compilation_error(Unsupported_field_type{field_name;field_type;backend_name}))letimport_file_not_foundfile_name=raise(Compilation_error(Import_file_not_foundfile_name))letprogrammatic_errore=raise(Compilation_error(Programatic_errore))letinvalid_import_qualifierloc=raise(Compilation_error(Invalid_import_qualifierloc))letinvalid_file_namefile_name=raise(Compilation_error(Invalid_file_namefile_name))letinvalid_packed_optionfield_name=raise(Compilation_error(Invalid_packed_optionfield_name))letmissing_semicolon_for_enum_valueenum_valueloc=raise(Compilation_error(Missing_semicolon_for_enum_value(enum_value,loc)))letinvalid_enum_specificationenum_nameloc=raise(Compilation_error(Invalid_enum_specification(enum_name,loc)))letinvalid_mutable_option?field_name()=raise(Compilation_error(Invalid_mutable_optionfield_name))letmissing_one_of_nameloc=raise(Compilation_error(Missing_one_of_nameloc))letmissing_field_label~field_name~message_name=raise(Compilation_error(Missing_field_label(field_name,message_name)))letinvalid_ppx_extension_optionmessage_name=raise(Compilation_error(Invalid_ppx_extension_optionmessage_name))letocamlyacc_parsing_errorloccontext=raise(Compilation_error(Parsing_error{msg="Parsing error";context;loc}))letprotoc_parsing_erroreloccontext=raise(Compilation_error(Parsing_error{msg=string_of_errore;context;loc}))letunknown_parsing_error~msg~contextloc=raise(Compilation_error(Parsing_error{msg;context;loc}))letinvalid_protobuf_syntaxsyntax=raise(Compilation_error(Invalid_protobuf_syntaxsyntax))letinvalid_proto3_field_label~field_name~message_name=raise(Compilation_error(Invalid_proto3_field_label(field_name,message_name)))letinvalid_rpc_req_type~service_name~rpc_name()=raise(Compilation_error(Invalid_rpc_req_type(service_name,rpc_name)))letinvalid_rpc_res_type~service_name~rpc_name()=raise(Compilation_error(Invalid_rpc_res_type(service_name,rpc_name)))letdefault_field_option_not_supported~field_name~message_name=raise(Compilation_error(Default_field_option_not_supported(field_name,message_name)))letinvalid_first_enum_value_proto3?message_name~enum_name()=raise(Compilation_error(Invalid_first_enum_value_proto3(enum_name,message_name)))letinvalid_key_type_for_mapfield_name=raise(Compilation_error(Invalid_key_type_for_mapfield_name))letunsupported_wrapper_typetype_name=raise(Compilation_error(Unsupported_wrapper_typetype_name))