---
title: "学会看Erlang的出错信息"
author: "high0048"
date: "2010-09-20T15:37:48Z"
tags: []
categories: ["编程语言"]
slug: "erlang"
draft: false
lastmod: "2010-09-20T15:38:44Z"
id: 768244
url: "https://high0048.iteye.com/blog/768244"
---

今天调试程序，冒出了这段

===ERROR REPORT==== 20-Sep-2010::15:33:53 ===
** Generic server my_bank terminating 
** Last message in was {add,"joe",10}
** When Server state == 20496
** Reason for termination == 
** {'function not exported',},
                             {my_bank,handle_call,3},
                             {gen_server,handle_msg,5},
                             {proc_lib,init_p_do_apply,3}]}
** exception exit: undef
     in function  ets:lookup/0
        called as ets:lookup()
     in call from my_bank:handle_call/3
     in call from gen_server:handle_msg/5
     in call from proc_lib:init_p_do_apply/3


晕啊，erlang的出错信息太难懂了，都是模式匹配 -_-！

Last message in was {add,"joe",10} ，这是指服务端最后一次收到的信息是{add,"joe",10}

{'function not exported',},
                             {my_bank,handle_call,3},
                             {gen_server,handle_msg,5},
                             {proc_lib,init_p_do_apply,3}]}
类似于java的堆栈信息，
这是指，函数未导出，外部调用的函数对外不可见
{ets,lookup,}指的是{模块名，函数名，参数}
后面类似。

本质原因是，ets:lookup/0 不存在，标准库只有ets:lookup/2这个函数，所以出错了！