我正在尝试处理我的api中的一些错误。但是,我尝试了许多方法来执行所需的操作?
在代码中,我使用了Exception \ Exception,这是另一个扩展到Exception的类“ use \ Exception”。这些选项均无效。我需要执行块捕获吗?
//Piece of source in the begin of file
namespace Business\Notifiers\Webhook;
use \Exception;
class MyException extends \Exception {}
//Piece of source from my class
try{
$products = $payment->getProducts();
if(count($products) == 0)
return;
$flight_id = $products[0]->flight_id;
$this->message = 'Sir, we have a new request: ';
$products = null; //Chagind it to null to force an error..
foreach($products as $product){
$this->appendAttachment(array(
'color' => '#432789',
'text' =>
"*Name:* $product->name $product->last_name \n" .
"*Total Paid:* R\$$product->price\n",
'mrkdwn_in' => …Run Code Online (Sandbox Code Playgroud) 我究竟做错了什么??
我正在尝试任何方式来获取POST数据但总是不起作用.那么它如何为null执行第一个condional响应就是badRequest("Expceting some data").
POST /pedidos/novo controllers.Pedidos.cadastraPedidoNoBanco
Run Code Online (Sandbox Code Playgroud)
@BodyParser.Of(BodyParser.Json.class)
public static Result cadastraPedidoNoBanco(){
JsonNode data = request().body().asJson();
if(data == null){
return badRequest("Expceting some data");
} else {
return ok(data);
}
}
Run Code Online (Sandbox Code Playgroud)
所以这没有发生任何错误,但我不知道为什么响应是这样的:
public static Result cadastraPedidoNoBanco(){
Map<String,String[]> data = request().body().asFormUrlEncoded();
if(data == null){
return badRequest("Expceting some data");
} else {
String response = "";
for(Map.Entry value : data.entrySet()){
response += "\n" + value.getValue();
}
return ok(response);
}
}
Run Code Online (Sandbox Code Playgroud)
[Ljava.lang.String;@5817f93f
[Ljava.lang.String;@decc448
[Ljava.lang.String;@334a5a1c
[Ljava.lang.String;@5661fe92
[Ljava.lang.String;@3b904f8c
[Ljava.lang.String;@7f568ee0 …Run Code Online (Sandbox Code Playgroud) 当我尝试创建一些但当我调用它时,出现错误1356:
创建视图
CREATE VIEW monitoring_consult AS (
SELECT
m.id,
account.valor AS 'phone_number',
IF((c.valor REGEXP '^[0-9]+$' OR c.valor IS NULL) AND cn.short_name IS NOT NULL, cn.short_name, c.valor) AS 'category',
IF(pn.id IS NOT NULL, pn.id, p.valor) AS 'provider',
n.valor AS 'nominal',
m.last_page,
pn.name AS 'provider_name',
IF(pay.valor is null, 'Uncompleted', pay.valor) AS 'payment',
timeEnd,
DATE_FORMAT(m.timeEnd, '%d/%m/%Y') as 'date'
FROM
monitoring AS m
LEFT JOIN feature AS account ON m.id = account.id AND account.valor IS NOT NULL AND (account.page = 'PV') AND account.type = …Run Code Online (Sandbox Code Playgroud)