为什么方法返回-1?

Ива*_*вац 0 java return-value

我从一本书中读取代码并使用此方法:

public int getScore(String name) {
  try {
     //some code here
     return score;
  } catch (Exception e) {
     e.printStackTrace();
     return -1;
  }
}
Run Code Online (Sandbox Code Playgroud)

为什么catch中的这个方法返回-1?为什么不5?这是一些约定吗?

rat*_*eak 11

-1是调用者期望正int时的标准错误代码

但实际上,在这种情况下,包裹RuntimeException或更具体的一个会好得多